diff --git a/mex/sources/bytecode/Interpreter.cc b/mex/sources/bytecode/Interpreter.cc
index df1e6c993fed78a58ac6dde179298334958da5ac..5cfd3089102bc169302bf15465b94f0c2ad63548 100644
--- a/mex/sources/bytecode/Interpreter.cc
+++ b/mex/sources/bytecode/Interpreter.cc
@@ -112,26 +112,32 @@ Interpreter::get_variable(SymbolType variable_type, int variable_num)
       C = mxGetN(mxGetFieldByNumber(M_, 0, mxGetFieldNumber(M_, "endo_names")));
       R = mxGetM(mxGetFieldByNumber(M_, 0, mxGetFieldNumber(M_, "endo_names")));
       P = (char*) mxGetPr(mxGetFieldByNumber(M_, 0, mxGetFieldNumber(M_, "endo_names")));
-      if (EQN_dvar1 < R)
+      if (variable_num < R)
         for (unsigned int i = 0; i < C; i++)
-          res << P[2*(EQN_dvar1+i*R)];
+          res << P[2*(variable_num+i*R)];
+      else
+        mexPrintf("=> Unknown endogenous variable n� %d",EQN_dvar1);
       break;
     case eExogenous:
     case eExogenousDet:
       C = mxGetN(mxGetFieldByNumber(M_, 0, mxGetFieldNumber(M_, "exo_names")));
       R = mxGetM(mxGetFieldByNumber(M_, 0, mxGetFieldNumber(M_, "exo_names")));
       P = (char*) mxGetPr(mxGetFieldByNumber(M_, 0, mxGetFieldNumber(M_, "exo_names")));
-      if (EQN_dvar1 < R)
+      if (variable_num < R)
         for (unsigned int i = 0; i < C; i++)
-          res << P[2*(EQN_dvar1+i*R)];
+          res << P[2*(variable_num+i*R)];
+      else
+        mexPrintf("=> Unknown exogenous variable n� %d",EQN_dvar1);
       break;
     case eParameter:
       C = mxGetN(mxGetFieldByNumber(M_, 0, mxGetFieldNumber(M_, "param_names")));
       R = mxGetM(mxGetFieldByNumber(M_, 0, mxGetFieldNumber(M_, "param_names")));
       P = (char*) mxGetPr(mxGetFieldByNumber(M_, 0, mxGetFieldNumber(M_, "param_names")));
-      if (EQN_dvar1 < R)
+      if (variable_num < R)
         for (unsigned int i = 0; i < C; i++)
-          res << P[2*(EQN_dvar1+i*R)];
+          res << P[2*(variable_num+i*R)];
+      else
+        mexPrintf("=> Unknown parameter n� %d",EQN_dvar1);
       break;
     default:
       break;
diff --git a/mex/sources/bytecode/SparseMatrix.cc b/mex/sources/bytecode/SparseMatrix.cc
index 17e81b424b9736834e71454ae5dfd32a77e394eb..4af23d9c67b18560a56173970e7f057052245a70 100644
--- a/mex/sources/bytecode/SparseMatrix.cc
+++ b/mex/sources/bytecode/SparseMatrix.cc
@@ -1832,7 +1832,7 @@ SparseMatrix::simulate_NG1(int blck, int y_size, int it_, int y_kmin, int y_kmax
                     {
                       if (nop+1 >= nopa)
                         {
-                          nopa = int (1.5*nopa);
+                          nopa = long (mem_increasing_factor*(double)nopa);
                           save_op = (int *) mxRealloc(save_op, nopa*sizeof(int));
                         }
                       save_op_s = (t_save_op_s *)(&(save_op[nop]));
@@ -1872,7 +1872,7 @@ SparseMatrix::simulate_NG1(int blck, int y_size, int it_, int y_kmin, int y_kmax
                         {
                           if (nop+j*2+1 >= nopa)
                             {
-                              nopa = int (1.5*nopa);
+                              nopa = long (mem_increasing_factor*(double)nopa);
                               save_op = (int *) mxRealloc(save_op, nopa*sizeof(int));
                             }
                           save_op_s = (t_save_op_s *)(&(save_op[nop+j*2]));
@@ -1891,7 +1891,7 @@ SparseMatrix::simulate_NG1(int blck, int y_size, int it_, int y_kmin, int y_kmax
                     {
                       if (nop+1 >= nopa)
                         {
-                          nopa = int (1.5*nopa);
+                          nopa = long (mem_increasing_factor*(double)nopa);
                           save_op = (int *) mxRealloc(save_op, nopa*sizeof(int));
                         }
                       save_op_s = (t_save_op_s *)(&(save_op[nop]));
@@ -1926,13 +1926,10 @@ SparseMatrix::simulate_NG1(int blck, int y_size, int it_, int y_kmin, int y_kmax
                     {
                       if (record)
                         {
-                          if (nop+2 >= nopa)
+                          if (nop+1 >= nopa)
                             {
-                              //#pragma omp critical
-                              {
-                                nopa = int (1.5*nopa);
-                                save_op = (int *) mxRealloc(save_op, nopa*sizeof(int));
-                              }
+                              nopa = long (mem_increasing_factor*(double)nopa);
+                              save_op = (int *) mxRealloc(save_op, nopa*sizeof(int));
                             }
                           save_op_s_l = (t_save_op_s *)(&(save_op[nop]));
                           save_op_s_l->operat = IFLD;
@@ -1979,11 +1976,8 @@ SparseMatrix::simulate_NG1(int blck, int y_size, int it_, int y_kmin, int y_kmax
                                 {
                                   if (nop+2 >= nopa)
                                     {
-                                      //#pragma omp critical
-                                      {
-                                        nopa = int (1.5*nopa);
-                                        save_op = (int *) mxRealloc(save_op, nopa*sizeof(int));
-                                      }
+                                      nopa = long (mem_increasing_factor*(double)nopa);
+                                      save_op = (int *) mxRealloc(save_op, nopa*sizeof(int));
                                     }
                                   save_op_s_l = (t_save_op_s *)(&(save_op[nop]));
                                   save_op_s_l->operat = IFLESS;
@@ -2037,11 +2031,8 @@ SparseMatrix::simulate_NG1(int blck, int y_size, int it_, int y_kmin, int y_kmax
                                     {
                                       if (nop+3 >= nopa)
                                         {
-                                          //#pragma omp critical
-                                          {
-                                            nopa = int (1.5*nopa);
-                                            save_op = (int *) mxRealloc(save_op, nopa*sizeof(int));
-                                          }
+                                          nopa = long (mem_increasing_factor*(double)nopa);
+                                          save_op = (int *) mxRealloc(save_op, nopa*sizeof(int));
                                         }
                                       save_op_s_l = (t_save_op_s *)(&(save_op[nop]));
                                       save_op_s_l->operat = IFSUB;
@@ -2074,11 +2065,8 @@ SparseMatrix::simulate_NG1(int blck, int y_size, int it_, int y_kmin, int y_kmax
                         {
                           if (nop+3 >= nopa)
                             {
-                              //#pragma omp critical
-                              {
-                                nopa = int (1.5*nopa);
-                                save_op = (int *) mxRealloc(save_op, nopa*sizeof(int));
-                              }
+                              nopa = long (mem_increasing_factor*(double)nopa);
+                              save_op = (int *) mxRealloc(save_op, nopa*sizeof(int));
                             }
                           save_op_s_l = (t_save_op_s *)(&(save_op[nop]));
                           save_op_s_l->operat = IFSUB;
diff --git a/mex/sources/bytecode/SparseMatrix.hh b/mex/sources/bytecode/SparseMatrix.hh
index c4d51afb8e47389f730d3592089e18cb03dad211..c7dd24a83749df288911fa3aa4f1bc3bbc14c9a0 100644
--- a/mex/sources/bytecode/SparseMatrix.hh
+++ b/mex/sources/bytecode/SparseMatrix.hh
@@ -94,6 +94,7 @@ const int IFADD = 7;
 const double eps = 1e-10;
 const double very_big = 1e24;
 const int alt_symbolic_count_max = 1;
+const double mem_increasing_factor = 1.1;
 
 class SparseMatrix
 {