diff --git a/matlab/global_initialization.m b/matlab/global_initialization.m
index 42b41b8160530042ec84287b75bdeab3ba18b919..db7e15acb36402de3c353806e13345d9ae3bfdbb 100644
--- a/matlab/global_initialization.m
+++ b/matlab/global_initialization.m
@@ -223,8 +223,7 @@ function global_initialization()
   options_.prior_analysis_endo_var_list = [];
   
   % block decomposition + minimum feedback set for steady state computation
-  options_.block_mfs = 0;
+  options_.block = 0;
 
-  % block decomposition + minimum feedback set for steady state computation
-  % using simulate.dll
-  options_.block_mfs_dll = 0;
+  % model evaluated using simulate.dll
+  options_.bytecode = 0;
diff --git a/matlab/solve_two_boundaries.m b/matlab/solve_two_boundaries.m
index b03e1244276b421838d2133bece3c1fd0b0b9527..1cca2bee1001ee9df47ec8e86af3e6bbf992c783 100644
--- a/matlab/solve_two_boundaries.m
+++ b/matlab/solve_two_boundaries.m
@@ -73,7 +73,6 @@ function y = solve_two_boundaries(fname, y, x, params, y_index, nze, periods, y_
   reduced = 0;
   while ~(cvg==1 | iter>maxit_),
     [r, y, g1, g2, g3, b]=feval(fname, y, x, params, periods, 0, y_kmin, Blck_size);
-
 %     fjac = zeros(Blck_size, Blck_size*(y_kmin_l+1+y_kmax_l));
 %     disp(['Blck_size=' int2str(Blck_size) ' size(y_index)=' int2str(size(y_index,2))]);
 %     dh = max(abs(y(y_kmin+1-y_kmin_l:y_kmin+1+y_kmax_l, y_index)),options_.gstep*ones(y_kmin_l+1+y_kmax_l, Blck_size))*eps^(1/3);
diff --git a/matlab/steady_.m b/matlab/steady_.m
index 269838de9ac56534a41e4f1a7062594c64b7bc6a..f884ad6f1d99a19f77177292e88ae0bfb1e019fe 100644
--- a/matlab/steady_.m
+++ b/matlab/steady_.m
@@ -62,7 +62,7 @@ function steady_()
 					      options_.jacobian_flag, ...	    
 					      [oo_.exo_steady_state;oo_.exo_det_steady_state],indv);
     end
-  elseif options_.block_mfs
+  elseif options_.block && ~options_.bytecode
     for b = 1:size(M_.blocksMFS,1)
       n = size(M_.blocksMFS{b}, 1);
       ss = oo_.steady_state;
@@ -79,7 +79,7 @@ function steady_()
                           [oo_.exo_steady_state; ...
                           oo_.exo_det_steady_state], M_.params);
     end
-  elseif options_.block_mfs_dll
+  elseif options_.block && options_.bytecode
       [oo_.steady_state,check] = simulate('steady_state');
   else
     [oo_.steady_state,check] = dynare_solve([M_.fname '_static'],...
diff --git a/preprocessor/BlockTriangular.cc b/preprocessor/BlockTriangular.cc
index 14c8063e275682d2a7cac176ade4a6aae20421b0..1810c3f696d3639a6f186d0c3b3a81164d00d5fa 100644
--- a/preprocessor/BlockTriangular.cc
+++ b/preprocessor/BlockTriangular.cc
@@ -129,7 +129,10 @@ BlockTriangular::Compute_Normalization(bool *IM, int equation_number, int prolog
   for (int i = 0; i < n; i++)
     for (int j = 0; j < n; j++)
       if (IM0[(i+prologue) * equation_number+j+prologue])
-        add_edge(i + n, j, g);
+        {
+        	//printf("equation=%3d variable=%3d\n",i,j);
+          add_edge(i + n, j, g);
+        }
 
   // Compute maximum cardinality matching
   typedef vector<graph_traits<BipartiteGraph>::vertex_descriptor> mate_map_t;
@@ -931,10 +934,7 @@ BlockTriangular::Normalize_and_BlockDecompose(bool *IM, Model_Block *ModelBlock,
   int count_Block, count_Equ;
   bool *SIM0, *SIM00;
 
-	SIM0 = (bool *) malloc(n * n * sizeof(bool));
-  memcpy(SIM0, IM_0, n*n*sizeof(bool));
-  Prologue_Epilogue(IM, prologue, epilogue, n, Index_Var_IM, Index_Equ_IM, SIM0);
-  free(SIM0);
+
 
   int counted = 0;
   if (prologue+epilogue < n)
@@ -963,8 +963,10 @@ BlockTriangular::Normalize_and_BlockDecompose(bool *IM, Model_Block *ModelBlock,
           memset(SIM0, 0, n*n*sizeof(bool));
           SIM00 = (bool *) malloc(n * n * sizeof(bool));
           memset(SIM00, 0, n*n*sizeof(bool));
+          //cout << "---------------------------------\n";
           for (map< pair< int, int >, double >::iterator iter = j_m.begin(); iter != j_m.end(); iter++)
             {
+            	//printf("iter->second=% 1.10f iter->first.first=%3d iter->first.second=%3d  bi=%f\n", iter->second, iter->first.first, iter->first.second, bi);
               if (fabs(iter->second) > max(bi, cutoff))
                 {
                   SIM0[iter->first.first*n+iter->first.second] = 1;
@@ -999,6 +1001,11 @@ BlockTriangular::Normalize_and_BlockDecompose(bool *IM, Model_Block *ModelBlock,
         }
     }
 
+  SIM0 = (bool *) malloc(n * n * sizeof(bool));
+  memcpy(SIM0, IM_0, n*n*sizeof(bool));
+  Prologue_Epilogue(IM, prologue, epilogue, n, Index_Var_IM, Index_Equ_IM, SIM0);
+  free(SIM0);
+
   V_Equation_Type = Equation_Type_determination(equations, first_order_endo_derivatives, Index_Var_IM, Index_Equ_IM, mfs);
 
   cout << "Finding the optimal block decomposition of the model ...\n";
diff --git a/preprocessor/ComputingTasks.cc b/preprocessor/ComputingTasks.cc
index 22ba5950ad6be4c2fac22614154cfce0d3639139..c21d02680c7e448f3c4b24462afde847d73ca47e 100644
--- a/preprocessor/ComputingTasks.cc
+++ b/preprocessor/ComputingTasks.cc
@@ -35,10 +35,6 @@ SteadyStatement::SteadyStatement(const OptionsList &options_list_arg, StaticDllM
 void
 SteadyStatement::checkPass(ModFileStructure &mod_file_struct)
 {
-  if (options_list.num_options.find("block_mfs") != options_list.num_options.end())
-    mod_file_struct.steady_block_mfs_option = true;
-  else if (options_list.num_options.find("block_mfs_dll") != options_list.num_options.end())
-    mod_file_struct.steady_block_mfs_dll_option = true;
 }
 
 void
@@ -86,8 +82,8 @@ void ModelInfoStatement::writeOutput(ostream &output, const string &basename) co
 }
 
 
-SimulStatement::SimulStatement(const OptionsList &options_list_arg, DynamicModel::mode_t mode_arg) :
-  options_list(options_list_arg), mode(mode_arg)
+SimulStatement::SimulStatement(const OptionsList &options_list_arg, DynamicModel::mode_t mode_arg, bool block_arg, bool byte_code_arg) :
+  options_list(options_list_arg), mode(mode_arg), byte_code(byte_code_arg), block(block_arg)
 {
 }
 
@@ -101,7 +97,7 @@ void
 SimulStatement::writeOutput(ostream &output, const string &basename) const
 {
   options_list.writeOutput(output);
-  if (mode == DynamicModel::eStandardMode || mode == DynamicModel::eDLLMode)
+  if ((mode == DynamicModel::eStandardMode || mode == DynamicModel::eDLLMode) && !block)
     output << "simul(oo_.dr);\n";
   else
     {
@@ -113,7 +109,7 @@ SimulStatement::writeOutput(ostream &output, const string &basename) const
              << "    read_data_;" << endl
              << "  end" << endl
              << "end" << endl;
-      if (mode == DynamicModel::eSparseDLLMode)
+      if (byte_code)
           output << "oo_.endo_simul=simulate;" << endl;
         else
           output << basename << "_dynamic;" << endl;
@@ -922,7 +918,7 @@ PlannerObjectiveStatement::computingPass()
 void
 PlannerObjectiveStatement::writeOutput(ostream &output, const string &basename) const
 {
-  model_tree->writeStaticFile(basename + "_objective");
+  model_tree->writeStaticFile(basename + "_objective", false);
 }
 
 BVARDensityStatement::BVARDensityStatement(int maxnlags_arg, const OptionsList &options_list_arg) :
diff --git a/preprocessor/ComputingTasks.hh b/preprocessor/ComputingTasks.hh
index 37f7ebc329ddd71e2ffa33b28f506e6412120ce9..4f06b07ab5972487393016e28fb50dfa7f595771 100644
--- a/preprocessor/ComputingTasks.hh
+++ b/preprocessor/ComputingTasks.hh
@@ -54,8 +54,10 @@ class SimulStatement : public Statement
 private:
   const OptionsList options_list;
   const DynamicModel::mode_t mode;
+  const bool byte_code;
+  const bool block;
 public:
-  SimulStatement(const OptionsList &options_list_arg, DynamicModel::mode_t mode_arg);
+  SimulStatement(const OptionsList &options_list_arg, DynamicModel::mode_t mode_arg, bool block_arg, bool byte_code_arg);
   virtual void checkPass(ModFileStructure &mod_file_struct);
   virtual void writeOutput(ostream &output, const string &basename) const;
 };
diff --git a/preprocessor/DynamicModel.cc b/preprocessor/DynamicModel.cc
index 89afb45582f2c5f5c38a5972766ad2309a95bf75..160d4098ab3dbe47f111470e987ce03c9f4be587 100644
--- a/preprocessor/DynamicModel.cc
+++ b/preprocessor/DynamicModel.cc
@@ -337,6 +337,7 @@ DynamicModel::writeModelEquationsOrdered_M( Model_Block *ModelBlock, const strin
         << "  % //                     Simulation type "
         << BlockTriangular::BlockSim(ModelBlock->Block_List[j].Simulation_Type) << "  //" << endl
         << "  % ////////////////////////////////////////////////////////////////////////" << endl;
+        output << "  global options_;" << endl;
         //The Temporary terms
         //output << "  relax = 1;\n";
         if (ModelBlock->Block_List[j].Simulation_Type==EVALUATE_BACKWARD
@@ -359,9 +360,9 @@ DynamicModel::writeModelEquationsOrdered_M( Model_Block *ModelBlock, const strin
             output << "  else\n";
             if (ModelBlock->Block_List[j].Simulation_Type==SOLVE_TWO_BOUNDARIES_COMPLETE || ModelBlock->Block_List[j].Simulation_Type==SOLVE_TWO_BOUNDARIES_SIMPLE)
               {
-                output << "    g1 = spalloc(" << (ModelBlock->Block_List[j].Size-ModelBlock->Block_List[j].Nb_Recursives)*ModelBlock->Periods
-                << ", " << (ModelBlock->Block_List[j].Size-ModelBlock->Block_List[j].Nb_Recursives)*(ModelBlock->Periods+ModelBlock->Block_List[j].Max_Lag+ModelBlock->Block_List[j].Max_Lead+1)
-                << ", " << nze*ModelBlock->Periods << ");\n";
+                output << "    g1 = spalloc(" << (ModelBlock->Block_List[j].Size-ModelBlock->Block_List[j].Nb_Recursives) << "*options_.periods, "
+                << (ModelBlock->Block_List[j].Size-ModelBlock->Block_List[j].Nb_Recursives) << "*(options_.periods+" << ModelBlock->Block_List[j].Max_Lag+ModelBlock->Block_List[j].Max_Lead+1 << ")"
+                << ", " << nze << "*options_.periods);\n";
                 /*output << "    g1_tmp_r = spalloc(" << (ModelBlock->Block_List[j].Nb_Recursives)
                 << ", " << (ModelBlock->Block_List[j].Size)*(ModelBlock->Block_List[j].Max_Lag+ModelBlock->Block_List[j].Max_Lead+1)
                 << ", " << nze << ");\n";
@@ -1278,7 +1279,6 @@ DynamicModel::Write_Inf_To_Bin_File(const string &dynamic_basename, const string
 			}
 
 
-
     /*for (int m=0;m<=block_triangular.ModelBlock->Block_List[num].Max_Lead+block_triangular.ModelBlock->Block_List[num].Max_Lag;m++)
       {
         int k1=m-block_triangular.ModelBlock->Block_List[num].Max_Lag;
@@ -1296,10 +1296,10 @@ DynamicModel::Write_Inf_To_Bin_File(const string &dynamic_basename, const string
       }*/
     if (is_two_boundaries)
       {
-        for (j=0;j<Size;j++)
+        /*for (j=0;j<Size;j++)
           {
             int eqr1=j;
-            int varr=/*block_triangular.ModelBlock->Block_List[num].Size*/Size*(block_triangular.periods
+            int varr=Size*(block_triangular.periods
                      +block_triangular.incidencematrix.Model_Max_Lead_Endo);
             int k1=0;
             SaveCode.write(reinterpret_cast<char *>(&eqr1), sizeof(eqr1));
@@ -1307,7 +1307,8 @@ DynamicModel::Write_Inf_To_Bin_File(const string &dynamic_basename, const string
             SaveCode.write(reinterpret_cast<char *>(&k1), sizeof(k1));
             SaveCode.write(reinterpret_cast<char *>(&eqr1), sizeof(eqr1));
             u_count_int++;
-          }
+          }*/
+				u_count_int+=Size;
       }
     //cout << "u_count_int=" << u_count_int << "\n";
     for (j=block_triangular.ModelBlock->Block_List[num].Nb_Recursives;j<block_triangular.ModelBlock->Block_List[num].Size;j++)
@@ -1687,7 +1688,7 @@ DynamicModel::writeDynamicModel(ostream &DynamicOutput) const
     ostringstream hessian_output;  // Used for storing Hessian equations
     ostringstream third_derivatives_output;
 
-    ExprNodeOutputType output_type = (mode == eStandardMode || mode==eSparseMode ? oMatlabDynamicModel : oCDynamicModel);
+    ExprNodeOutputType output_type = (mode != eDLLMode ? oMatlabDynamicModel : oCDynamicModel);
 
     writeModelLocalVariables(model_output, output_type);
 
@@ -1889,12 +1890,12 @@ DynamicModel::writeDynamicModel(ostream &DynamicOutput) const
   }
 
 void
-DynamicModel::writeOutput(ostream &output, const string &basename) const
+DynamicModel::writeOutput(ostream &output, const string &basename, bool block) const
   {
     output << "options_.model_mode = " << mode << ";" << endl;
 
     // Erase possible remnants of previous runs
-    if (mode != eStandardMode)
+    if (mode != eStandardMode || block)
       output << "delete('" << basename << "_dynamic.m');" << endl;
     if (mode != eDLLMode)
       output << "erase_compiled_function('" + basename + "_dynamic');" << endl;
@@ -1902,7 +1903,7 @@ DynamicModel::writeOutput(ostream &output, const string &basename) const
     // Special setup for DLL or Sparse modes
     if (mode == eDLLMode)
       output << "mex -O LDFLAGS='-pthread -shared -Wl,--no-undefined' " << basename << "_dynamic.c" << endl;
-    if (mode == eSparseMode || mode == eSparseDLLMode)
+    if (block)
       output << "addpath " << basename << ";" << endl;
 
     /* Writing initialisation for M_.lead_lag_incidence matrix
@@ -1938,7 +1939,7 @@ DynamicModel::writeOutput(ostream &output, const string &basename) const
     output << "]';" << endl;
     //In case of sparse model, writes the block structure of the model
 
-    if (mode==eSparseMode || mode==eSparseDLLMode)
+    if (block)
       {
         //int prev_Simulation_Type=-1;
         //bool skip_the_head;
@@ -2137,9 +2138,9 @@ DynamicModel::writeOutput(ostream &output, const string &basename) const
   }
 
 void
-DynamicModel::writeOutputPostComputing(ostream &output, const string &basename) const
+DynamicModel::writeOutputPostComputing(ostream &output, const string &basename, bool block) const
 {
-  if (mode == eSparseMode || mode == eSparseDLLMode)
+  if (block)
     output << "rmpath " << basename << ";" << endl;
 }
 
@@ -2300,7 +2301,7 @@ DynamicModel::collect_first_order_derivatives_endogenous()
 
 void
 DynamicModel::computingPass(bool jacobianExo, bool hessian, bool thirdDerivatives, bool paramsDerivatives,
-                            const eval_context_type &eval_context, bool no_tmp_terms)
+                            const eval_context_type &eval_context, bool no_tmp_terms, bool block)
 {
   assert(jacobianExo || !(hessian || thirdDerivatives || paramsDerivatives));
 
@@ -2343,7 +2344,7 @@ DynamicModel::computingPass(bool jacobianExo, bool hessian, bool thirdDerivative
       computeThirdDerivatives(vars);
     }
 
-  if (mode == eSparseDLLMode || mode == eSparseMode)
+  if (block)
     {
       BuildIncidenceMatrix();
 
@@ -2375,10 +2376,48 @@ DynamicModel::computingPass(bool jacobianExo, bool hessian, bool thirdDerivative
 }
 
 void
-DynamicModel::writeDynamicFile(const string &basename) const
+DynamicModel::writeDynamicFile(const string &basename, bool block, bool bytecode) const
   {
     int r;
-    switch (mode)
+    if(block && bytecode)
+      {
+#ifdef _WIN32
+        r = mkdir(basename.c_str());
+#else
+        r = mkdir(basename.c_str(), 0777);
+#endif
+        if (r < 0 && errno != EEXIST)
+          {
+            perror("ERROR");
+            exit(EXIT_FAILURE);
+          }
+        writeModelEquationsCodeOrdered(basename + "_dynamic", block_triangular.ModelBlock, basename, map_idx);
+        block_triangular.Free_Block(block_triangular.ModelBlock);
+        block_triangular.incidencematrix.Free_IM();
+        //block_triangular.Free_IM_X(block_triangular.First_IM_X);
+      }
+		else if(block && !bytecode)
+		  {
+#ifdef _WIN32
+        r = mkdir(basename.c_str());
+#else
+        r = mkdir(basename.c_str(), 0777);
+#endif
+        if (r < 0 && errno != EEXIST)
+          {
+            perror("ERROR");
+            exit(EXIT_FAILURE);
+          }
+        writeSparseDynamicMFile(basename + "_dynamic", basename, mode);
+        block_triangular.Free_Block(block_triangular.ModelBlock);
+        block_triangular.incidencematrix.Free_IM();
+        //block_triangular.Free_IM_X(block_triangular.First_IM_X);
+		  }
+		else if (mode == eDLLMode)
+     	writeDynamicCFile(basename + "_dynamic");
+		else if (mode == eStandardMode)
+		  writeDynamicMFile(basename + "_dynamic");
+    /*switch (mode)
       {
       case eStandardMode:
         writeDynamicMFile(basename + "_dynamic");
@@ -2419,7 +2458,7 @@ DynamicModel::writeDynamicFile(const string &basename) const
         block_triangular.incidencematrix.Free_IM();
         //block_triangular.Free_IM_X(block_triangular.First_IM_X);
         break;
-      }
+      }*/
   }
 
 void
diff --git a/preprocessor/DynamicModel.hh b/preprocessor/DynamicModel.hh
index ee05ea9546316b56694b12dce96eaaf59aea6bd6..21c935b8f929605b3737d4a819427e4ab6ef8dd6 100644
--- a/preprocessor/DynamicModel.hh
+++ b/preprocessor/DynamicModel.hh
@@ -36,9 +36,9 @@ public:
   enum mode_t
   {
     eStandardMode, //!< Standard mode (dynamic file in Matlab)
-    eSparseMode,   //!< Sparse mode (dynamic file in Matlab with block decomposition)
-    eDLLMode,      //!< DLL mode (dynamic file in C)
-    eSparseDLLMode //!< Sparse DLL mode (dynamic file in C with block decomposition plus a binary file)
+    //eSparseMode,   //!< Sparse mode (dynamic file in Matlab with block decomposition)
+    eDLLMode      //!< DLL mode (dynamic file in C)
+    //eSparseDLLMode //!< Sparse DLL mode (dynamic file in C with block decomposition plus a binary file)
   };
 private:
   typedef map<pair<int, int>, int> deriv_id_table_t;
@@ -174,18 +174,18 @@ public:
     \param no_tmp_terms if true, no temporary terms will be computed in the dynamic files
   */
   void computingPass(bool jacobianExo, bool hessian, bool thirdDerivatives, bool paramsDerivatives,
-                     const eval_context_type &eval_context, bool no_tmp_terms);
+                     const eval_context_type &eval_context, bool no_tmp_terms, bool block);
   //! Writes model initialization and lead/lag incidence matrix to output
-  void writeOutput(ostream &output, const string &basename) const;
+  void writeOutput(ostream &output, const string &basename, bool block) const;
   //! Write statements to be added to the main M-file, after computational tasks
-  void writeOutputPostComputing(ostream &output, const string &basename) const;
+  void writeOutputPostComputing(ostream &output, const string &basename, bool block) const;
   //! Complete set to block decompose the model
   BlockTriangular block_triangular;
   //! Adds informations for simulation in a binary file
   void Write_Inf_To_Bin_File(const string &dynamic_basename, const string &bin_basename,
                              const int &num, int &u_count_int, bool &file_open, bool is_two_boundaries) const;
   //! Writes dynamic model file
-  void writeDynamicFile(const string &basename) const;
+  void writeDynamicFile(const string &basename, bool block, bool bytecode) const;
   //! Writes file containing parameters derivatives
   void writeParamsDerivativesFile(const string &basename) const;
   //! Converts to static model (only the equations)
diff --git a/preprocessor/DynareBison.yy b/preprocessor/DynareBison.yy
index 864ffd3ab786a6cb8305a267a6de59bb5da6f591..5e17458be055e9be4132b72f3f598cc42e9e0542 100644
--- a/preprocessor/DynareBison.yy
+++ b/preprocessor/DynareBison.yy
@@ -87,11 +87,11 @@ class ParsingDriver;
 %}
 
 %token AR AUTOCORR
-%token BAYESIAN_IRF BETA_PDF BICGSTAB BLOCK_MFS BLOCK_MFS_DLL
+%token BAYESIAN_IRF BETA_PDF BICGSTAB BLOCK
 %token BVAR_DENSITY BVAR_FORECAST
 %token BVAR_PRIOR_DECAY BVAR_PRIOR_FLAT BVAR_PRIOR_LAMBDA
 %token BVAR_PRIOR_MU BVAR_PRIOR_OMEGA BVAR_PRIOR_TAU BVAR_PRIOR_TRAIN
-%token BVAR_REPLIC
+%token BVAR_REPLIC BYTECODE
 %token CALIB CALIB_VAR CHANGE_TYPE CHECK CONF_SIG CONSTANT CORR COVAR CUTOFF
 %token DATAFILE DR_ALGO DROP DSAMPLE DYNASAVE DYNATYPE
 %token END ENDVAL EQUAL ESTIMATION ESTIMATED_PARAMS ESTIMATED_PARAMS_BOUNDS ESTIMATED_PARAMS_INIT
@@ -119,7 +119,7 @@ class ParsingDriver;
 %token QZ_CRITERIUM
 %token RELATIVE_IRF REPLIC RPLOT SAVE_PARAMS_AND_STEADY_STATE
 %token SHOCKS SIGMA_E SIMUL SIMUL_ALGO SIMUL_SEED SMOOTHER SOLVE_ALGO
-%token SPARSE SPARSE_DLL STDERR STEADY STOCH_SIMUL
+%token STDERR STEADY STOCH_SIMUL
 %token TEX RAMSEY_POLICY PLANNER_DISCOUNT
 %token <string_val> TEX_NAME
 %token UNIFORM_PDF UNIT_ROOT_VARS USE_DLL SHOCK_DECOMPOSITION LABELS
@@ -143,8 +143,8 @@ class ParsingDriver;
 %token FREQ INITIAL_YEAR INITIAL_SUBPERIOD FINAL_YEAR FINAL_SUBPERIOD DATA VLIST VARLIST VLISTLOG VLISTPER
 %token RESTRICTION_FNAME NLAGS CROSS_RESTRICTIONS CONTEMP_REDUCED_FORM REAL_PSEUDO_FORECAST BAYESIAN_PRIOR
 %token DUMMY_OBS NSTATES INDXSCALESSTATES ALPHA BETA GSIG2_LMD GSIG2_LMDM Q_DIAG FLAT_PRIOR NCSK NSTD NINV
-%token INDXPARR INDXOVR ABAND INDXAP APBAND INDXIMF IMFBAND INDXFORE FOREBAND INDXGFOREHAT INDXGIMFHAT 
-%token INDXESTIMA INDXGDLS EQ_MS CMS NCMS EQ_CMS TLINDX TLNUMBER CNUM BANACT 
+%token INDXPARR INDXOVR ABAND INDXAP APBAND INDXIMF IMFBAND INDXFORE FOREBAND INDXGFOREHAT INDXGIMFHAT
+%token INDXESTIMA INDXGDLS EQ_MS CMS NCMS EQ_CMS TLINDX TLNUMBER CNUM BANACT
 %token SBVAR MS_SBVAR
 
 %type <node_val> expression expression_or_empty
@@ -155,7 +155,7 @@ class ParsingDriver;
 %type <string_val> vec_value_1 vec_value
 %type <string_val> calib_arg2 range number
 %type <symbol_type_val> change_type_arg
-%type <vector_string_val> change_type_var_list 
+%type <vector_string_val> change_type_var_list
 
 %%
 
@@ -443,14 +443,24 @@ histval_list : histval_list histval_elem
 
 histval_elem : symbol '(' signed_integer ')' EQUAL expression ';' { driver.hist_val($1, $3, $6); };
 
-model_sparse_options_list : model_sparse_options_list COMMA model_sparse_options
-                          | model_sparse_options
+/*model_block_options_list : model_block_options_list COMMA model_block_options
+                         | model_block_options
                           ;
 
-model_sparse_options : o_cutoff
-                     | o_markowitz
-                     | o_mfs
+model_block_options : o_cutoff
+										| o_mfs
                      ;
+*/
+
+model_options : BLOCK {driver.block(); }
+							| o_cutoff
+							| o_mfs
+              | BYTECODE {driver.byte_code();}
+              ;
+
+model_options_list : model_options_list COMMA model_options
+                   | model_options
+                   ;
 
 model : MODEL ';' { driver.begin_model(); }
         equation_list END { driver.reset_data_tree(); }
@@ -458,15 +468,7 @@ model : MODEL ';' { driver.begin_model(); }
         equation_list END { driver.reset_data_tree(); }
       | MODEL '(' USE_DLL ')' ';' { driver.begin_model(); driver.use_dll(); }
         equation_list END { driver.reset_data_tree(); }
-      | MODEL '(' SPARSE_DLL COMMA model_sparse_options_list ')'
-        { driver.begin_model(); driver.sparse_dll(); } ';'
-        equation_list END { driver.reset_data_tree(); }
-      | MODEL '(' SPARSE_DLL ')' { driver.begin_model(); driver.sparse_dll(); } ';'
-        equation_list END { driver.reset_data_tree(); }
-      | MODEL '(' SPARSE COMMA model_sparse_options_list ')'
-        { driver.begin_model(); driver.sparse(); } ';'
-        equation_list END { driver.reset_data_tree(); }
-      | MODEL '(' SPARSE ')' { driver.begin_model(); driver.sparse(); } ';'
+      | MODEL '(' model_options_list ')' ';' { driver.begin_model(); }
         equation_list END { driver.reset_data_tree(); }
       ;
 
@@ -641,11 +643,7 @@ steady_options_list : steady_options_list COMMA steady_options
 steady_options : o_solve_algo
                | o_homotopy_mode
                | o_homotopy_steps
-               | o_block_mfs
-               | o_block_mfs_dll
-               | o_cutoff
                | o_markowitz
-               | o_mfs
                ;
 
 check : CHECK ';'
@@ -677,6 +675,7 @@ simul_options_list : simul_options_list COMMA simul_options
 simul_options : o_periods
               | o_datafile
               | o_method
+							| o_markowitz
               ;
 
 stoch_simul : STOCH_SIMUL ';'
@@ -733,7 +732,7 @@ symbol_list_ext : symbol_list
                     driver.add_in_symbol_list(colon);
                   }
                 ;
-                     
+
 list_of_symbol_lists : symbol_list ';' symbol
                        {
                          string *semicolon = new string(";");
@@ -1259,53 +1258,53 @@ bvar_forecast : BVAR_FORECAST INT_NUMBER ';'
               ;
 
 sbvar_option : o_datafile
-             | o_freq 
-             | o_initial_year 
-             | o_initial_subperiod 
-             | o_final_year 
-             | o_final_subperiod 
-             | o_data 
-             | o_vlist 
-             | o_vlistlog 
-             | o_vlistper 
-             | o_varlist 
-             | o_restriction_fname 
-             | o_nlags 
-             | o_cross_restrictions 
-             | o_contemp_reduced_form 
-             | o_real_pseudo_forecast 
-             | o_bayesian_prior 
-             | o_dummy_obs 
-             | o_nstates 
-             | o_indxscalesstates 
-             | o_alpha 
-             | o_beta 
-             | o_gsig2_lmd 
-             | o_gsig2_lmdm 
-             | o_q_diag 
-             | o_flat_prior 
-             | o_ncsk 
-             | o_nstd 
-             | o_ninv 
-             | o_indxparr 
-             | o_indxovr 
-             | o_aband 
-             | o_indxap 
-             | o_apband 
-             | o_indximf 
-             | o_indxfore 
-             | o_foreband 
-             | o_indxgforhat 
-             | o_indxgimfhat 
-             | o_indxestima 
-             | o_indxgdls 
-             | o_eq_ms 
-             | o_cms 
-             | o_ncms 
-             | o_eq_cms 
-             | o_tlindx 
-             | o_tlnumber 
-             | o_cnum 
+             | o_freq
+             | o_initial_year
+             | o_initial_subperiod
+             | o_final_year
+             | o_final_subperiod
+             | o_data
+             | o_vlist
+             | o_vlistlog
+             | o_vlistper
+             | o_varlist
+             | o_restriction_fname
+             | o_nlags
+             | o_cross_restrictions
+             | o_contemp_reduced_form
+             | o_real_pseudo_forecast
+             | o_bayesian_prior
+             | o_dummy_obs
+             | o_nstates
+             | o_indxscalesstates
+             | o_alpha
+             | o_beta
+             | o_gsig2_lmd
+             | o_gsig2_lmdm
+             | o_q_diag
+             | o_flat_prior
+             | o_ncsk
+             | o_nstd
+             | o_ninv
+             | o_indxparr
+             | o_indxovr
+             | o_aband
+             | o_indxap
+             | o_apband
+             | o_indximf
+             | o_indxfore
+             | o_foreband
+             | o_indxgforhat
+             | o_indxgimfhat
+             | o_indxestima
+             | o_indxgdls
+             | o_eq_ms
+             | o_cms
+             | o_ncms
+             | o_eq_cms
+             | o_tlindx
+             | o_tlnumber
+             | o_cnum
              ;
 
 sbvar_options_list : sbvar_option COMMA sbvar_options_list
@@ -1319,53 +1318,53 @@ sbvar : SBVAR ';'
       ;
 
 ms_sbvar_option : o_datafile
-                | o_freq 
-                | o_initial_year 
-                | o_initial_subperiod 
-                | o_final_year 
-                | o_final_subperiod 
-                | o_data 
-                | o_vlist 
-                | o_vlistlog 
-                | o_vlistper 
-                | o_varlist 
-                | o_restriction_fname 
-                | o_nlags 
-                | o_cross_restrictions 
-                | o_contemp_reduced_form 
-                | o_real_pseudo_forecast 
-                | o_bayesian_prior 
-                | o_dummy_obs 
-                | o_nstates 
-                | o_indxscalesstates 
-                | o_alpha 
-                | o_beta 
-                | o_gsig2_lmd 
-                | o_gsig2_lmdm 
-                | o_q_diag 
-                | o_flat_prior 
-                | o_ncsk 
-                | o_nstd 
-                | o_ninv 
-                | o_indxparr 
-                | o_indxovr 
-                | o_aband 
-                | o_indxap 
-                | o_apband 
-                | o_indximf 
-                | o_indxfore 
-                | o_foreband 
-                | o_indxgforhat 
-                | o_indxgimfhat 
-                | o_indxestima 
-                | o_indxgdls 
-                | o_eq_ms 
-                | o_cms 
-                | o_ncms 
-                | o_eq_cms 
-                | o_tlindx 
-                | o_tlnumber 
-                | o_cnum 
+                | o_freq
+                | o_initial_year
+                | o_initial_subperiod
+                | o_final_year
+                | o_final_subperiod
+                | o_data
+                | o_vlist
+                | o_vlistlog
+                | o_vlistper
+                | o_varlist
+                | o_restriction_fname
+                | o_nlags
+                | o_cross_restrictions
+                | o_contemp_reduced_form
+                | o_real_pseudo_forecast
+                | o_bayesian_prior
+                | o_dummy_obs
+                | o_nstates
+                | o_indxscalesstates
+                | o_alpha
+                | o_beta
+                | o_gsig2_lmd
+                | o_gsig2_lmdm
+                | o_q_diag
+                | o_flat_prior
+                | o_ncsk
+                | o_nstd
+                | o_ninv
+                | o_indxparr
+                | o_indxovr
+                | o_aband
+                | o_indxap
+                | o_apband
+                | o_indximf
+                | o_indxfore
+                | o_foreband
+                | o_indxgforhat
+                | o_indxgimfhat
+                | o_indxestima
+                | o_indxgdls
+                | o_eq_ms
+                | o_cms
+                | o_ncms
+                | o_eq_cms
+                | o_tlindx
+                | o_tlnumber
+                | o_cnum
                 ;
 
 ms_sbvar_options_list : ms_sbvar_option COMMA ms_sbvar_options_list
@@ -1607,8 +1606,7 @@ o_gsa_trans_ident : TRANS_IDENT EQUAL INT_NUMBER { driver.option_num("trans_iden
 
 o_homotopy_mode : HOMOTOPY_MODE EQUAL INT_NUMBER {driver.option_num("homotopy_mode",$3); };
 o_homotopy_steps : HOMOTOPY_STEPS EQUAL INT_NUMBER {driver.option_num("homotopy_steps",$3); };
-o_block_mfs : BLOCK_MFS { driver.option_num("block_mfs", "1"); }
-o_block_mfs_dll : BLOCK_MFS_DLL { driver.option_num("block_mfs_dll", "1"); }
+
 
 o_parameters : PARAMETERS EQUAL symbol {driver.option_str("parameters",$3);};
 o_shocks : SHOCKS EQUAL '(' list_of_symbol_lists ')' { driver.option_symbol_list("shocks"); };
@@ -1624,7 +1622,7 @@ o_vlist : VLIST EQUAL INT_NUMBER {driver.option_num("ms.vlist",$3); };
 o_vlistlog : VLISTLOG EQUAL INT_NUMBER {driver.option_num("ms.vlistlog",$3); };
 o_vlistper : VLISTPER EQUAL INT_NUMBER {driver.option_num("ms.vlistper",$3); };
 o_varlist : VARLIST EQUAL '(' symbol_list ')' {driver.option_symbol_list("ms.varlist"); };
-o_restriction_fname : RESTRICTION_FNAME EQUAL symbol {driver.option_str("ms.restriction_fname",$3); };
+o_restriction_fname : RESTRICTION_FNAME EQUAL '(' symbol_list ')' {driver.option_symbol_list("ms.restriction_fname"); };
 o_nlags : NLAGS EQUAL INT_NUMBER {driver.option_num("ms.nlags",$3); };
 o_cross_restrictions : CROSS_RESTRICTIONS EQUAL INT_NUMBER {driver.option_num("ms.cross_restrictions",$3); };
 o_contemp_reduced_form : CONTEMP_REDUCED_FORM EQUAL INT_NUMBER {driver.option_num("ms.contemp_reduced_form",$3); };
diff --git a/preprocessor/DynareFlex.ll b/preprocessor/DynareFlex.ll
index 395050c03e5871efbde0ccb3103ae381c34d5026..97c7570c06f68b7a09f1b4fd07e7281dfbfac2d6 100644
--- a/preprocessor/DynareFlex.ll
+++ b/preprocessor/DynareFlex.ll
@@ -220,8 +220,6 @@ int sigma_e = 0;
 <DYNARE_STATEMENT>filename      {return token::FILENAME;}
 <DYNARE_STATEMENT>diffuse_filter {return token::DIFFUSE_FILTER;}
 <DYNARE_STATEMENT>plot_priors   {return token::PLOT_PRIORS;}
-<DYNARE_STATEMENT>block_mfs {return token::BLOCK_MFS;}
-<DYNARE_STATEMENT>block_mfs_dll {return token::BLOCK_MFS_DLL;}
 
 <DYNARE_STATEMENT>freq {return token::FREQ;}
 <DYNARE_STATEMENT>initial_year {return token::INITIAL_YEAR;}
@@ -349,8 +347,8 @@ int sigma_e = 0;
 <DYNARE_STATEMENT,DYNARE_BLOCK>gaussian_elimination {return token::GAUSSIAN_ELIMINATION;}
 <DYNARE_STATEMENT,DYNARE_BLOCK>gmres {return token::GMRES;}
 <DYNARE_STATEMENT,DYNARE_BLOCK>bicgstab {return token::BICGSTAB;}
-<DYNARE_STATEMENT,DYNARE_BLOCK>sparse {return token::SPARSE;}
-<DYNARE_STATEMENT,DYNARE_BLOCK>sparse_dll {return token::SPARSE_DLL;}
+<DYNARE_STATEMENT,DYNARE_BLOCK>block {return token::BLOCK;}
+<DYNARE_STATEMENT,DYNARE_BLOCK>bytecode {return token::BYTECODE;}
 <DYNARE_STATEMENT,DYNARE_BLOCK>linear {return token::LINEAR;}
 <DYNARE_STATEMENT,DYNARE_BLOCK>[,] {return token::COMMA;}
 <DYNARE_STATEMENT,DYNARE_BLOCK>[:] {return Dynare::parser::token_type (yytext[0]);}
diff --git a/preprocessor/ModFile.cc b/preprocessor/ModFile.cc
index c5bb7914828ae47430f6ce92bfa9c5e385ed460f..9a8816a12d78ac2ddee8ac7ca56daa48d404589d 100644
--- a/preprocessor/ModFile.cc
+++ b/preprocessor/ModFile.cc
@@ -29,6 +29,8 @@ ModFile::ModFile() : expressions_tree(symbol_table, num_constants),
                      dynamic_model(symbol_table, num_constants),
                      linear(false)
 {
+	block = false;
+	byte_code = false;
 }
 
 ModFile::~ModFile()
@@ -144,20 +146,23 @@ ModFile::computingPass(bool no_tmp_terms)
   if (dynamic_model.equation_number() > 0)
     {
       // Compute static model and its derivatives
-      if(mod_file_struct.steady_block_mfs_dll_option)
+      cout << "byte_code=" << byte_code << endl;
+      cout << "block=" << block << endl;
+      if(byte_code)
         {
+        	cout << "go in DLL\n";
           dynamic_model.toStaticDll(static_dll_model);
-          static_dll_model.computingPass(global_eval_context, no_tmp_terms);
+          static_dll_model.computingPass(global_eval_context, no_tmp_terms, block);
         }
       else
         {
           dynamic_model.toStatic(static_model);
-          static_model.computingPass(mod_file_struct.steady_block_mfs_option, false, no_tmp_terms);
+          static_model.computingPass(block, false, no_tmp_terms);
         }
       // Set things to compute for dynamic model
 
       if (mod_file_struct.simul_present)
-        dynamic_model.computingPass(false, false, false, false, global_eval_context, no_tmp_terms);
+        dynamic_model.computingPass(false, false, false, false, global_eval_context, no_tmp_terms, block);
       else
         {
           if (mod_file_struct.order_option < 1 || mod_file_struct.order_option > 3)
@@ -168,7 +173,7 @@ ModFile::computingPass(bool no_tmp_terms)
           bool hessian = mod_file_struct.order_option >= 2;
           bool thirdDerivatives = mod_file_struct.order_option == 3;
           bool paramsDerivatives = mod_file_struct.identification_present;
-          dynamic_model.computingPass(true, hessian, thirdDerivatives, paramsDerivatives, global_eval_context, no_tmp_terms);
+          dynamic_model.computingPass(true, hessian, thirdDerivatives, paramsDerivatives, global_eval_context, no_tmp_terms, false);
         }
     }
 
@@ -235,11 +240,14 @@ ModFile::writeOutputFiles(const string &basename, bool clear_all) const
 
   if (dynamic_model.equation_number() > 0)
     {
-      dynamic_model.writeOutput(mOutputFile, basename);
-      if(mod_file_struct.steady_block_mfs_dll_option)
-        static_dll_model.writeOutput(mOutputFile, basename);
+    	if (mod_file_struct.simul_present)
+        dynamic_model.writeOutput(mOutputFile, basename, block);
+			else
+			  dynamic_model.writeOutput(mOutputFile, basename, false);
+      if(byte_code)
+        static_dll_model.writeOutput(mOutputFile, basename, block);
       else
-        static_model.writeOutput(mOutputFile);
+        static_model.writeOutput(mOutputFile, block);
     }
 
   // Print statements
@@ -248,7 +256,12 @@ ModFile::writeOutputFiles(const string &basename, bool clear_all) const
     (*it)->writeOutput(mOutputFile, basename);
 
   if (dynamic_model.equation_number() > 0)
-    dynamic_model.writeOutputPostComputing(mOutputFile, basename);
+    {
+      if (mod_file_struct.simul_present)
+        dynamic_model.writeOutputPostComputing(mOutputFile, basename, block);
+			else
+			  dynamic_model.writeOutputPostComputing(mOutputFile, basename, false);
+    }
 
   mOutputFile << "save('" << basename << "_results.mat', 'oo_', 'M_', 'options_');" << endl
               << "diary off" << endl
@@ -259,11 +272,14 @@ ModFile::writeOutputFiles(const string &basename, bool clear_all) const
   // Create static and dynamic files
   if (dynamic_model.equation_number() > 0)
     {
-      if(mod_file_struct.steady_block_mfs_dll_option)
-        static_dll_model.writeStaticFile(basename);
+      if(byte_code)
+        static_dll_model.writeStaticFile(basename, block);
       else
-        static_model.writeStaticFile(basename);
-      dynamic_model.writeDynamicFile(basename);
+        static_model.writeStaticFile(basename, block);
+			if (mod_file_struct.simul_present)
+        dynamic_model.writeDynamicFile(basename, block, byte_code);
+			else
+			  dynamic_model.writeDynamicFile(basename, false, false);
       dynamic_model.writeParamsDerivativesFile(basename);
     }
 
diff --git a/preprocessor/ModFile.hh b/preprocessor/ModFile.hh
index c7f4647eca871e2bcd0da161710b82176e4db2f4..80d31c25d61946c51600e4052fa32b97c3f0a212 100644
--- a/preprocessor/ModFile.hh
+++ b/preprocessor/ModFile.hh
@@ -53,6 +53,14 @@ public:
   DynamicModel dynamic_model;
   //! Option linear
   bool linear;
+
+  //! Is the model block decomposed?
+  bool block;
+
+  //! Is the model stored in baytecode format (byte_code=true) or in a M-file (byte_code=false)
+  bool byte_code;
+
+
   //! Global evaluation context
   /*! Filled using initval blocks and parameters initializations */
   eval_context_type global_eval_context;
diff --git a/preprocessor/ParsingDriver.cc b/preprocessor/ParsingDriver.cc
index fd8a2258351b24afd2fca0a51dd7e992777e3842..4216f66fe12000aea6c8ec94aef9c74ff55bbc35 100644
--- a/preprocessor/ParsingDriver.cc
+++ b/preprocessor/ParsingDriver.cc
@@ -183,7 +183,7 @@ ParsingDriver::add_model_variable(string *name, string *olag)
   if (type == eUnknownFunction)
     error("Symbol " + *name + " is a function name unknown to Dynare. It cannot be used inside model.");
 
-  if (type == eExogenous && lag != 0 && (dynamic_model->mode != DynamicModel::eSparseDLLMode && dynamic_model->mode != DynamicModel::eSparseMode))
+  if (type == eExogenous && lag != 0 && !mod_file->block)
     warning("Exogenous variable " + *name + " has lead/lag " + *olag);
 
   if (type == eModelLocalVariable && lag != 0)
@@ -351,15 +351,15 @@ ParsingDriver::use_dll()
 }
 
 void
-ParsingDriver::sparse_dll()
+ParsingDriver::block()
 {
-  dynamic_model->mode = DynamicModel::eSparseDLLMode;
+  mod_file->block = true;
 }
 
 void
-ParsingDriver::sparse()
+ParsingDriver::byte_code()
 {
-  dynamic_model->mode = DynamicModel::eSparseMode;
+  mod_file->byte_code = true;
 }
 
 void
@@ -617,7 +617,7 @@ ParsingDriver::option_num(const string &name_option, const string &opt)
       && (options_list.num_options.find(name_option) != options_list.num_options.end()))
     error("option " + name_option + " declared twice");
 
-  if ((name_option == "periods") && (mod_file->dynamic_model.mode == DynamicModel::eSparseDLLMode || mod_file->dynamic_model.mode == DynamicModel::eSparseMode))
+  if ((name_option == "periods") && mod_file->block)
     mod_file->dynamic_model.block_triangular.periods = atoi(opt.c_str());
   else if (name_option == "cutoff")
     {
@@ -629,8 +629,6 @@ ParsingDriver::option_num(const string &name_option, const string &opt)
 		  mod_file->dynamic_model.mfs = atoi(opt.c_str());
 		  mod_file->static_dll_model.mfs = atoi(opt.c_str());
 	  }
-	else if (name_option == "block_mfs_dll")
-	  mod_file->static_dll_model.mode = (StaticDllModel::mode_t)DynamicModel::eSparseDLLMode;
 
   options_list.num_options[name_option] = opt;
 }
@@ -695,7 +693,7 @@ void ParsingDriver::stoch_simul()
 void
 ParsingDriver::simul()
 {
-  mod_file->addStatement(new SimulStatement(options_list, mod_file->dynamic_model.mode));
+  mod_file->addStatement(new SimulStatement(options_list, mod_file->dynamic_model.mode, mod_file->block, mod_file->byte_code));
   options_list.clear();
 }
 
@@ -1095,14 +1093,14 @@ ParsingDriver::ms_sbvar()
   options_list.clear();
 }
 
-void 
+void
 ParsingDriver::shock_decomposition()
 {
   mod_file->addStatement(new ShockDecompositionStatement(symbol_list, options_list));
   symbol_list.clear();
   options_list.clear();
 }
-  
+
 NodeID
 ParsingDriver::add_model_equal(NodeID arg1, NodeID arg2)
 {
diff --git a/preprocessor/ParsingDriver.hh b/preprocessor/ParsingDriver.hh
index 6d27a7bfdadc37fea5d6f2a003c73d40634a15a0..8d6b1f5847d35572faa528ce4ce529213f7d0aaa 100644
--- a/preprocessor/ParsingDriver.hh
+++ b/preprocessor/ParsingDriver.hh
@@ -175,10 +175,10 @@ public:
   bool symbol_exists_and_is_not_modfile_local_or_unknown_function(const char *s);
   //! Sets mode of ModelTree class to use C output
   void use_dll();
-  //! Sets mode of ModelTree class to block decompose the model and triggers the creation of the incidence matrix in a C context
-  void sparse_dll();
-  //! Sets mode of ModelTree class to block decompose the model and triggers the creation of the incidence matrix in Matlab context
-  void sparse();
+  //! the modelis block decomposed
+  void block();
+  //! the model is stored in a binary file
+  void byte_code();
   //! Sets the FILENAME for the initial value in initval
   void initval_file(string *filename);
   //! Declares an endogenous variable
diff --git a/preprocessor/StaticDllModel.cc b/preprocessor/StaticDllModel.cc
index da6cf82389fd7fd4a9e70eef0531ff3976337a09..e186e2b025ca787cfde62ede6a19ba7e5f6750cb 100644
--- a/preprocessor/StaticDllModel.cc
+++ b/preprocessor/StaticDllModel.cc
@@ -824,8 +824,10 @@ StaticDllModel::writeSparseStaticMFile(const string &static_basename, const stri
 
 
 void
-StaticDllModel::writeOutput(ostream &output, const string &basename) const
+StaticDllModel::writeOutput(ostream &output, const string &basename, bool block) const
 {
+	  output << "options_.block=" << block << ";" << endl;
+	  output << "options_.bytecode=1;" << endl;
     output << "options_.model_mode = " << mode << ";" << endl;
 
     // Erase possible remnants of previous runs
@@ -837,14 +839,14 @@ StaticDllModel::writeOutput(ostream &output, const string &basename) const
     // Special setup for DLL or Sparse modes
     if (mode == eDLLMode)
       output << "mex -O LDFLAGS='-pthread -shared -Wl,--no-undefined' " << basename << "_static.c" << endl;
-    if (mode == eSparseMode || mode == eSparseDLLMode)
+    if (block)
       output << "addpath " << basename << ";" << endl;
 }
 
 void
-StaticDllModel::writeOutputPostComputing(ostream &output, const string &basename) const
+StaticDllModel::writeOutputPostComputing(ostream &output, const string &basename, bool block) const
 {
-  if (mode == eSparseMode || mode == eSparseDLLMode)
+  if (block)
     output << "rmpath " << basename << ";" << endl;
 }
 
@@ -1004,7 +1006,7 @@ StaticDllModel::collect_first_order_derivatives_endogenous()
 
 
 void
-StaticDllModel::computingPass(const eval_context_type &eval_context, bool no_tmp_terms)
+StaticDllModel::computingPass(const eval_context_type &eval_context, bool no_tmp_terms, bool block)
 {
 
   // Computes static jacobian columns
@@ -1025,7 +1027,7 @@ StaticDllModel::computingPass(const eval_context_type &eval_context, bool no_tmp
   << " - order 1" << endl;
   computeJacobian(vars);
   //cout << "mode=" << mode << " eSparseDLLMode=" << eSparseDLLMode << " eSparseMode=" << eSparseMode << "\n";
-  if (mode == eSparseDLLMode || mode == eSparseMode)
+  if (block)
     {
       BuildIncidenceMatrix();
 
@@ -1067,10 +1069,29 @@ StaticDllModel::computingPass(const eval_context_type &eval_context, bool no_tmp
 }
 
 void
-StaticDllModel::writeStaticFile(const string &basename) const
+StaticDllModel::writeStaticFile(const string &basename, bool block) const
   {
     int r;
-    switch (mode)
+		if(block)
+		  {
+#ifdef _WIN32
+        r = mkdir(basename.c_str());
+#else
+        r = mkdir(basename.c_str(), 0777);
+#endif
+        if (r < 0 && errno != EEXIST)
+          {
+            perror("ERROR");
+            exit(EXIT_FAILURE);
+          }
+        writeModelEquationsCodeOrdered(basename + "_static", block_triangular.ModelBlock, basename, map_idx);
+        block_triangular.Free_Block(block_triangular.ModelBlock);
+        block_triangular.incidencematrix.Free_IM();
+		  }
+		else
+		  {
+		  }
+    /*switch (mode)
       {
       case eStandardMode:
         break;
@@ -1109,7 +1130,7 @@ StaticDllModel::writeStaticFile(const string &basename) const
         block_triangular.incidencematrix.Free_IM();
         //block_triangular.Free_IM_X(block_triangular.First_IM_X);
         break;
-      }
+      }*/
   }
 
 
diff --git a/preprocessor/StaticDllModel.hh b/preprocessor/StaticDllModel.hh
index dd067710ee3ef504affc504467e174a5547e8484..8812a1d6c5cc4b0b39137258dd6a5d250d9e0a3d 100644
--- a/preprocessor/StaticDllModel.hh
+++ b/preprocessor/StaticDllModel.hh
@@ -35,9 +35,9 @@ public:
   enum mode_t
   {
     eStandardMode, //!< Standard mode (static file in Matlab)
-    eSparseMode,   //!< Sparse mode (static file in Matlab with block decomposition)
-    eDLLMode,      //!< DLL mode (static file in C)
-    eSparseDLLMode //!< Sparse DLL mode (static file in C with block decomposition plus a binary file)
+    //eSparseMode,   //!< Sparse mode (static file in Matlab with block decomposition)
+    eDLLMode       //!< DLL mode (static file in C)
+    //eSparseDLLMode //!< Sparse DLL mode (static file in C with block decomposition plus a binary file)
   };
 private:
   typedef map<pair<int, int>, int> deriv_id_table_t;
@@ -167,18 +167,18 @@ public:
     \param eval_context evaluation context for normalization
     \param no_tmp_terms if true, no temporary terms will be computed in the static files
   */
-  void computingPass(const eval_context_type &eval_context, bool no_tmp_terms);
+  void computingPass(const eval_context_type &eval_context, bool no_tmp_terms, bool block);
   //! Writes model initialization and lead/lag incidence matrix to output
-  void writeOutput(ostream &output, const string &basename) const;
+  void writeOutput(ostream &output, const string &basename, bool block) const;
   //! Write statements to be added to the main M-file, after computational tasks
-  void writeOutputPostComputing(ostream &output, const string &basename) const;
+  void writeOutputPostComputing(ostream &output, const string &basename, bool block) const;
   //! Complete set to block decompose the model
   BlockTriangular block_triangular;
   //! Adds informations for simulation in a binary file
   void Write_Inf_To_Bin_File(const string &static_basename, const string &bin_basename,
                              const int &num, int &u_count_int, bool &file_open) const;
   //! Writes static model file
-  void writeStaticFile(const string &basename) const;
+  void writeStaticFile(const string &basename, bool block) const;
   //! Writes file containing parameters derivatives
   void writeParamsDerivativesFile(const string &basename) const;
 
diff --git a/preprocessor/StaticModel.cc b/preprocessor/StaticModel.cc
index 486fd59744ef7be31e7c23b958d2e2b73c4184c6..bda4f1ec5d1926989f45de493cd9ecb5b3353384 100644
--- a/preprocessor/StaticModel.cc
+++ b/preprocessor/StaticModel.cc
@@ -45,8 +45,7 @@ using namespace boost;
 
 StaticModel::StaticModel(SymbolTable &symbol_table_arg,
                          NumericalConstants &num_constants_arg) :
-  ModelTree(symbol_table_arg, num_constants_arg),
-  block_mfs(false)
+  ModelTree(symbol_table_arg, num_constants_arg)
 {
 }
 
@@ -158,7 +157,7 @@ StaticModel::writeStaticMFile(ostream &output, const string &func_name) const
 }
 
 void
-StaticModel::writeStaticFile(const string &basename) const
+StaticModel::writeStaticFile(const string &basename, bool block) const
 {
   string filename = basename + "_static.m";
 
@@ -170,7 +169,7 @@ StaticModel::writeStaticFile(const string &basename) const
       exit(EXIT_FAILURE);
     }
 
-  if (block_mfs)
+  if (block)
     writeStaticBlockMFSFile(output, basename + "_static");
   else
     writeStaticMFile(output, basename + "_static");
@@ -179,9 +178,9 @@ StaticModel::writeStaticFile(const string &basename) const
 }
 
 void
-StaticModel::computingPass(bool block_mfs_arg, bool hessian, bool no_tmp_terms)
+StaticModel::computingPass(bool block, bool hessian, bool no_tmp_terms)
 {
-  block_mfs = block_mfs_arg;
+
 
   // Compute derivatives w.r. to all endogenous
   set<int> vars;
@@ -199,7 +198,7 @@ StaticModel::computingPass(bool block_mfs_arg, bool hessian, bool no_tmp_terms)
       computeHessian(vars);
     }
 
-  if (block_mfs)
+  if (block)
     {
       computeNormalization();
       computeSortedBlockDecomposition();
@@ -555,9 +554,9 @@ StaticModel::computeBlockMFSJacobian()
 }
 
 void
-StaticModel::writeOutput(ostream &output) const
+StaticModel::writeOutput(ostream &output, bool block) const
 {
-  if (!block_mfs)
+  if (!block)
     return;
 
   output << "M_.blocksMFS = cell(" << blocksMFS.size() << ", 1);" << endl;
@@ -574,7 +573,6 @@ StaticModel::writeLocalVars(ostream &output, NodeID expr, set<int> &local_var_wr
 {
   set<int> expr_local_var;
   expr->collectModelLocalVariables(expr_local_var);
-  
   vector<int> new_local_var;
   set_difference(expr_local_var.begin(), expr_local_var.end(),
                  local_var_written.begin(), local_var_written.end(),
diff --git a/preprocessor/StaticModel.hh b/preprocessor/StaticModel.hh
index 6adc1ee277b728fd07ac282d3125b2932dbe90de..ac4dda213ce3bde9360083af03b4e42a737dd226 100644
--- a/preprocessor/StaticModel.hh
+++ b/preprocessor/StaticModel.hh
@@ -27,9 +27,6 @@
 class StaticModel : public ModelTree
 {
 private:
-  //! Are we in block decomposition + min. feedback set mode ?
-  bool block_mfs;
-
   //! Normalization of equations
   /*! Maps endogenous type specific IDs to equation numbers */
   vector<int> endo2eq;
@@ -95,13 +92,13 @@ public:
     \param block_mfs whether block decomposition and minimum feedback set should be computed
     \param hessian whether Hessian (w.r. to endogenous only) should be computed
     \param no_tmp_terms if true, no temporary terms will be computed in the static and dynamic files */
-  void computingPass(bool block_mfs_arg, bool hessian, bool no_tmp_terms);
+  void computingPass(bool block, bool hessian, bool no_tmp_terms);
 
   //! Writes information on block decomposition when relevant
-  void writeOutput(ostream &output) const;
+  void writeOutput(ostream &output, bool block) const;
 
   //! Writes static model file
-  void writeStaticFile(const string &basename) const;
+  void writeStaticFile(const string &basename, bool block) const;
 
   //! Writes LaTeX file with the equations of the static model
   void writeLatexFile(const string &basename) const;
diff --git a/tests/ferhat/fs2000.mod b/tests/ferhat/fs2000.mod
index e85eaf6556d03f90f5884b7f0a5c8b0cb7ffd039..8d6a8f3d189ed18710f8eb20c5ccb7f5a6040631 100644
--- a/tests/ferhat/fs2000.mod
+++ b/tests/ferhat/fs2000.mod
@@ -32,7 +32,7 @@ psi = 0.787;
 del = 0.02;
 toto = [2  3];
 
-model(sparse_dll);
+model(block, bytecode);
 //model(sparse);
 //model;
 /*0*/  exp(gam+e_a) = dA ;
diff --git a/tests/ferhat/ireland.mod b/tests/ferhat/ireland.mod
index 79875d08ca20b8a0c52f223740fc35a868c7ff12..b5ca4100c72534894fb806e626c478aa1da54c59 100644
--- a/tests/ferhat/ireland.mod
+++ b/tests/ferhat/ireland.mod
@@ -23,9 +23,9 @@ scy = 0.0040;
 shy = 0.0015;
 shc = 0.0010;
 
-//model(sparse_dll, cutoff=0);
-model(sparse,cutoff=0);
-//model(sparse);
+//model(block, bytecode, cutoff=0);
+model(block,cutoff=0);
+//model(block);
 //model;
 exp(y) = exp(a)*exp(k(-1))^theta*exp(h)^(1-theta);
 a = (1-rho)*aa+rho*a(-1)+e;
diff --git a/tests/ferhat/ls2003.mod b/tests/ferhat/ls2003.mod
index be9abd6994b7560e0678504f2993c2bf61ba8a11..8dd2eb7bec0e8fd0960b4dae3a9760872321d6ae 100644
--- a/tests/ferhat/ls2003.mod
+++ b/tests/ferhat/ls2003.mod
@@ -17,7 +17,7 @@ rho_ys = 0.9;
 rho_pies = 0.7;
 
 
-model(sparse_dll, markowitz=0, cutoff=0);
+model(block, bytecode, cutoff=0);
 //model(sparse);
 //model;
 y = y(+1) - (tau +alpha*(2-alpha)*(1-tau))*(R-pie(+1))-alpha*(tau +alpha*(2-alpha)*(1-tau))*dq(+1) + alpha*(2-alpha)*((1-tau)/tau)*(y_s-y_s(+1))-A(+1);
@@ -93,7 +93,7 @@ values 0.5;
 end;
 
 //simul(periods=200,method=bicgstab);
-simul(periods=20);
+simul(periods=20, markowitz=0);
 rplot vv;
 rplot ww;
 rplot A;
diff --git a/tests/ferhat/mod1.mod b/tests/ferhat/mod1.mod
index 6eae1d0eca3ec39fa5bb0a6cdee6f3aad7509191..16abb20afab77cfe3bb210cb1e2521b70584a4e2 100644
--- a/tests/ferhat/mod1.mod
+++ b/tests/ferhat/mod1.mod
@@ -6,7 +6,7 @@ parameters rho_x rho_y;
 rho_x = 0.5;
 rho_y = -0.3;
 
-model(sparse);
+model(block);
 dx = rho_x*dx(-1)+e_x;
 dy = rho_y*dy(-1)+e_y;
 x = x(-1)+dx;
diff --git a/tests/ferhat/multimod.mod b/tests/ferhat/multimod.mod
index ce3858bdfc3475c3472917263fcb01d73696ff07..194b9121bbba584ad49e80ce97765c888fc109fd 100644
--- a/tests/ferhat/multimod.mod
+++ b/tests/ferhat/multimod.mod
@@ -852,7 +852,7 @@ W0906=0.0800069594276;
 W0907=0.147854375051;
 W0908=0.206834342322;
 W0909=-1;
-model(SPARSE_DLL,markowitz=3, mfs = 3);
+model(block, bytecode, mfs = 3, cutoff =0);
 //model(SPARSE,markowitz=2.0);
 //model;
  ( log(US_CPI)-(log(US_CPI(-1)))) = US_CPI1*( log(US_PIM)-(log(US_PIM(-1))))+US_CPI2*( log(US_PGNP)-(log(US_PGNP(-1))))+(1-US_CPI1-US_CPI2)*log(US_CPI(-1)/US_CPI(-2))+RES_US_CPI ;
@@ -2753,7 +2753,7 @@ options_.dynatol = 1e-4;
 options_.maxit_ = 5;
 
 
-simul(periods=80,datafile=mark3);
+simul(periods=80,datafile=mark3,markowitz=3);
 
 
 //simul(periods=10,datafile=mark3, method=lu);
diff --git a/tests/ferhat/ramst.mod b/tests/ferhat/ramst.mod
index 1b6caf92f5580b6c1a6ba361d5563970009654b5..5890b4e0c9ceb0f5765003406f954e265b744a85 100644
--- a/tests/ferhat/ramst.mod
+++ b/tests/ferhat/ramst.mod
@@ -10,8 +10,8 @@ bet=0.05;
 aa=0.5;
 
 
-//model(sparse);
-model(sparse_dll);
+//model(block, mfs=3);
+model(block, bytecode, mfs=3);
 //model;
 //s = aa*x*k(-1)^alph - c;
 c + k - aa*x*k(-1)^alph - (1-delt)*k(-1);// + 0.00000001*s;
diff --git a/tests/ferhat/ramst_a.mod b/tests/ferhat/ramst_a.mod
index 4789f354901c93047172b657b7283eb3ce72b772..57c8923addf62bb4641b8cc3110bdd168033433a 100644
--- a/tests/ferhat/ramst_a.mod
+++ b/tests/ferhat/ramst_a.mod
@@ -10,7 +10,7 @@ bet=0.05;
 aa=0.5;
 
 
-model(sparse);
+model(block);
 c + k - aa*x*k(-1)^alph - (1-delt)*k(-1);
 c^(-gam) - (1+bet)^(-1)*(aa*alph*x(+1)*k^(alph-1) + 1 - delt)*c(+1)^(-gam);
 end;