diff --git a/src/CodeInterpreter.hh b/src/CodeInterpreter.hh
index 8d9631497fc2c59f1ae198ad23ad68c75edd1641..e9ff2a28f67c1544161ad12d703b301cfdf2128f 100644
--- a/src/CodeInterpreter.hh
+++ b/src/CodeInterpreter.hh
@@ -1,5 +1,5 @@
 /*
- * Copyright © 2007-2018 Dynare Team
+ * Copyright © 2007-2019 Dynare Team
  *
  * This file is part of Dynare.
  *
@@ -482,7 +482,7 @@ public:
   {
   };
   inline explicit
-  FLDC_(const double value_arg) : TagWithOneArgument<double>::TagWithOneArgument{FLDC, value_arg}
+  FLDC_(double value_arg) : TagWithOneArgument<double>::TagWithOneArgument{FLDC, value_arg}
   {
   };
   inline double
@@ -500,7 +500,7 @@ public:
   {
   };
   inline explicit
-  FLDU_(const unsigned int pos_arg) : TagWithOneArgument<unsigned int>::TagWithOneArgument{FLDU, pos_arg}
+  FLDU_(unsigned int pos_arg) : TagWithOneArgument<unsigned int>::TagWithOneArgument{FLDU, pos_arg}
   {
   };
   inline unsigned int
@@ -518,7 +518,7 @@ public:
   {
   };
   inline explicit
-  FLDSU_(const unsigned int pos_arg) : TagWithOneArgument<unsigned int>::TagWithOneArgument{FLDSU, pos_arg}
+  FLDSU_(unsigned int pos_arg) : TagWithOneArgument<unsigned int>::TagWithOneArgument{FLDSU, pos_arg}
   {
   };
   inline unsigned int
@@ -536,7 +536,7 @@ public:
   {
   };
   inline explicit
-  FLDR_(const unsigned int pos_arg) : TagWithOneArgument<unsigned int>::TagWithOneArgument{FLDR, pos_arg}
+  FLDR_(unsigned int pos_arg) : TagWithOneArgument<unsigned int>::TagWithOneArgument{FLDR, pos_arg}
   {
   };
   inline unsigned int
@@ -554,7 +554,7 @@ public:
   {
   };
   inline explicit
-  FLDT_(const unsigned int pos_arg) : TagWithOneArgument<unsigned int>::TagWithOneArgument{FLDT, pos_arg}
+  FLDT_(unsigned int pos_arg) : TagWithOneArgument<unsigned int>::TagWithOneArgument{FLDT, pos_arg}
   {
   };
   inline unsigned int
@@ -572,7 +572,7 @@ public:
   {
   };
   inline explicit
-  FLDST_(const unsigned int pos_arg) : TagWithOneArgument<unsigned int>::TagWithOneArgument{FLDST, pos_arg}
+  FLDST_(unsigned int pos_arg) : TagWithOneArgument<unsigned int>::TagWithOneArgument{FLDST, pos_arg}
   {
   };
   inline unsigned int
@@ -590,7 +590,7 @@ public:
   {
   };
   inline explicit
-  FSTPT_(const unsigned int pos_arg) : TagWithOneArgument<unsigned int>::TagWithOneArgument{FSTPT, pos_arg}
+  FSTPT_(unsigned int pos_arg) : TagWithOneArgument<unsigned int>::TagWithOneArgument{FSTPT, pos_arg}
   {
   };
   inline unsigned int
@@ -608,7 +608,7 @@ public:
   {
   };
   inline explicit
-  FSTPST_(const unsigned int pos_arg) : TagWithOneArgument<unsigned int>::TagWithOneArgument{FSTPST, pos_arg}
+  FSTPST_(unsigned int pos_arg) : TagWithOneArgument<unsigned int>::TagWithOneArgument{FSTPST, pos_arg}
   {
   };
   inline unsigned int
@@ -626,7 +626,7 @@ public:
   {
   };
   inline explicit
-  FSTPR_(const unsigned int pos_arg) : TagWithOneArgument<unsigned int>::TagWithOneArgument{FSTPR, pos_arg}
+  FSTPR_(unsigned int pos_arg) : TagWithOneArgument<unsigned int>::TagWithOneArgument{FSTPR, pos_arg}
   {
   };
   inline unsigned int
@@ -644,7 +644,7 @@ public:
   {
   };
   inline explicit
-  FSTPU_(const unsigned int pos_arg) : TagWithOneArgument<unsigned int>::TagWithOneArgument{FSTPU, pos_arg}
+  FSTPU_(unsigned int pos_arg) : TagWithOneArgument<unsigned int>::TagWithOneArgument{FSTPU, pos_arg}
   {
   };
   inline unsigned int
@@ -662,7 +662,7 @@ public:
   {
   };
   inline explicit
-  FSTPSU_(const unsigned int pos_arg) : TagWithOneArgument<unsigned int>::TagWithOneArgument{FSTPSU, pos_arg}
+  FSTPSU_(unsigned int pos_arg) : TagWithOneArgument<unsigned int>::TagWithOneArgument{FSTPSU, pos_arg}
   {
   };
   inline unsigned int
@@ -680,7 +680,7 @@ public:
   {
   };
   inline explicit
-  FSTPG_(const unsigned int pos_arg) : TagWithOneArgument<unsigned int>::TagWithOneArgument{FSTPG, pos_arg}
+  FSTPG_(unsigned int pos_arg) : TagWithOneArgument<unsigned int>::TagWithOneArgument{FSTPG, pos_arg}
   {
   };
   inline unsigned int
@@ -698,7 +698,7 @@ public:
   {
   };
   inline
-  FSTPG2_(const unsigned int pos_arg1, const unsigned int pos_arg2) : TagWithTwoArguments<unsigned int, unsigned int>::TagWithTwoArguments{FSTPG2, pos_arg1, pos_arg2}
+  FSTPG2_(unsigned int pos_arg1, unsigned int pos_arg2) : TagWithTwoArguments<unsigned int, unsigned int>::TagWithTwoArguments{FSTPG2, pos_arg1, pos_arg2}
   {
   };
   inline unsigned int
@@ -721,7 +721,7 @@ public:
   {
   };
   inline
-  FSTPG3_(const unsigned int pos_arg1, const unsigned int pos_arg2, const int pos_arg3, const unsigned int pos_arg4) : TagWithFourArguments<unsigned int, unsigned int, int, unsigned int>::TagWithFourArguments{FSTPG3, pos_arg1, pos_arg2, pos_arg3, pos_arg4}
+  FSTPG3_(unsigned int pos_arg1, unsigned int pos_arg2, int pos_arg3, unsigned int pos_arg4) : TagWithFourArguments<unsigned int, unsigned int, int, unsigned int>::TagWithFourArguments{FSTPG3, pos_arg1, pos_arg2, pos_arg3, pos_arg4}
   {
   };
   inline unsigned int
@@ -772,7 +772,7 @@ public:
   {
   };
   inline explicit
-  FBINARY_(const int op_type_arg) : TagWithOneArgument<uint8_t>::TagWithOneArgument{FBINARY, static_cast<uint8_t>(op_type_arg)}
+  FBINARY_(int op_type_arg) : TagWithOneArgument<uint8_t>::TagWithOneArgument{FBINARY, static_cast<uint8_t>(op_type_arg)}
   {
   };
   inline uint8_t
@@ -790,7 +790,7 @@ public:
   {
   };
   inline explicit
-  FTRINARY_(const int op_type_arg) : TagWithOneArgument<uint8_t>::TagWithOneArgument{FTRINARY, static_cast<uint8_t>(op_type_arg)}
+  FTRINARY_(int op_type_arg) : TagWithOneArgument<uint8_t>::TagWithOneArgument{FTRINARY, static_cast<uint8_t>(op_type_arg)}
   {
   };
   inline uint8_t
@@ -808,7 +808,7 @@ public:
   {
   };
   inline explicit
-  FOK_(const int arg_arg) : TagWithOneArgument<int>::TagWithOneArgument{FOK, arg_arg}
+  FOK_(int arg_arg) : TagWithOneArgument<int>::TagWithOneArgument{FOK, arg_arg}
   {
   };
   inline int
@@ -1000,7 +1000,7 @@ public:
   {
   };
   inline
-  FLDVS_(uint8_t type_arg, const unsigned int pos_arg) : TagWithTwoArguments<uint8_t, unsigned int>::TagWithTwoArguments{FLDVS, type_arg, pos_arg}
+  FLDVS_(uint8_t type_arg, unsigned int pos_arg) : TagWithTwoArguments<uint8_t, unsigned int>::TagWithTwoArguments{FLDVS, type_arg, pos_arg}
   {
   };
   inline uint8_t
@@ -1023,7 +1023,7 @@ public:
   {
   };
   inline
-  FLDSV_(const uint8_t type_arg, const unsigned int pos_arg) :
+  FLDSV_(uint8_t type_arg, unsigned int pos_arg) :
     TagWithTwoArguments<uint8_t, unsigned int>::TagWithTwoArguments{FLDSV, type_arg, pos_arg}
   {
   };
@@ -1047,7 +1047,7 @@ public:
   {
   };
   inline
-  FSTPSV_(const uint8_t type_arg, const unsigned int pos_arg) :
+  FSTPSV_(uint8_t type_arg, unsigned int pos_arg) :
     TagWithTwoArguments<uint8_t, unsigned int>::TagWithTwoArguments{FSTPSV, type_arg, pos_arg}
   {
   };
@@ -1071,12 +1071,12 @@ public:
   {
   };
   inline
-  FLDV_(const int type_arg, const unsigned int pos_arg) :
+  FLDV_(int type_arg, unsigned int pos_arg) :
     TagWithThreeArguments<uint8_t, unsigned int, int>::TagWithThreeArguments{FLDV, static_cast<uint8_t>(type_arg), pos_arg, 0}
   {
   };
   inline
-  FLDV_(const int type_arg, const unsigned int pos_arg, const int lead_lag_arg) :
+  FLDV_(int type_arg, unsigned int pos_arg, int lead_lag_arg) :
     TagWithThreeArguments<uint8_t, unsigned int, int>::TagWithThreeArguments{FLDV, static_cast<uint8_t>(type_arg), pos_arg, lead_lag_arg}
   {
   };
@@ -1105,12 +1105,12 @@ public:
   {
   };
   inline
-  FSTPV_(const int type_arg, const unsigned int pos_arg) :
+  FSTPV_(int type_arg, unsigned int pos_arg) :
     TagWithThreeArguments<uint8_t, unsigned int, int>::TagWithThreeArguments{FSTPV, static_cast<uint8_t>(type_arg), pos_arg, 0}
   {
   };
   inline
-  FSTPV_(const int type_arg, const unsigned int pos_arg, const int lead_lag_arg) :
+  FSTPV_(int type_arg, unsigned int pos_arg, int lead_lag_arg) :
     TagWithThreeArguments<uint8_t, unsigned int, int>::TagWithThreeArguments{FSTPV, static_cast<uint8_t>(type_arg), pos_arg, lead_lag_arg}
   {
   };
@@ -1139,24 +1139,22 @@ class FCALL_ : public TagWithFourArguments<unsigned int, unsigned int, string, u
   ExternalFunctionType function_type;
 public:
   inline
-  FCALL_() : TagWithFourArguments<unsigned int, unsigned int, string, unsigned int>::TagWithFourArguments{FCALL}
+  FCALL_() : TagWithFourArguments<unsigned int, unsigned int, string, unsigned int>::TagWithFourArguments{FCALL},
+    add_input_arguments{0},
+    row{0},
+    col{0},
+    function_type{ExternalFunctionType::withoutDerivative}
   {
-    arg_func_name = "";
-    add_input_arguments = 0;
-    row = 0;
-    col = 0;
-    function_type = ExternalFunctionType::withoutDerivative;
   };
   inline
   FCALL_(unsigned int nb_output_arguments, unsigned int nb_input_arguments, string f_name, unsigned int indx) :
-    TagWithFourArguments<unsigned int, unsigned int, string, unsigned int>::TagWithFourArguments{FCALL, nb_output_arguments, nb_input_arguments, f_name, indx}
-  {
-    arg_func_name = "";
-    add_input_arguments = 0;
-    row = 0;
-    col = 0;
-    function_type = ExternalFunctionType::withoutDerivative;
-    func_name = f_name;
+    TagWithFourArguments<unsigned int, unsigned int, string, unsigned int>::TagWithFourArguments{FCALL, nb_output_arguments, nb_input_arguments, f_name, indx},
+    func_name{f_name},
+    add_input_arguments{0},
+    row{0},
+    col{0},
+    function_type{ExternalFunctionType::withoutDerivative}
+  {
   };
   inline string
   get_function_name()
diff --git a/src/ComputingTasks.cc b/src/ComputingTasks.cc
index 28464a2c089374188c40aeb183ae0b52018b4430..3aec80e26300a7493e178fc5de2f81c426776c36 100644
--- a/src/ComputingTasks.cc
+++ b/src/ComputingTasks.cc
@@ -223,8 +223,8 @@ PriorPosteriorFunctionStatement::PriorPosteriorFunctionStatement(const bool prio
 void
 PriorPosteriorFunctionStatement::checkPass(ModFileStructure &mod_file_struct, WarningConsolidation &warnings)
 {
-  auto it2 = options_list.string_options.find("function");
-  if (it2 == options_list.string_options.end() || it2->second.empty())
+  if (auto it2 = options_list.string_options.find("function");
+      it2 == options_list.string_options.end() || it2->second.empty())
     {
       cerr << "ERROR: both the prior_function and posterior_function commands require the 'function' argument"
            << endl;
@@ -236,9 +236,7 @@ void
 PriorPosteriorFunctionStatement::writeOutput(ostream &output, const string &basename, bool minimal_workspace) const
 {
   options_list.writeOutput(output);
-  string type = "posterior";
-  if (prior_func)
-    type = "prior";
+  string type = prior_func ? "prior" : "posterior";
 
   output << "oo_ = execute_prior_posterior_function("
          << "'" << options_list.string_options.find("function")->second << "', "
@@ -249,9 +247,7 @@ PriorPosteriorFunctionStatement::writeOutput(ostream &output, const string &base
 void
 PriorPosteriorFunctionStatement::writeJsonOutput(ostream &output) const
 {
-  string type = "posterior";
-  if (prior_func)
-    type = "prior";
+  string type = prior_func ? "prior" : "posterior";
   output << R"({"statementName": "prior_posterior_function", "type": ")" << type << R"(")";
   if (options_list.getNumberOfOptions())
     {
@@ -289,7 +285,7 @@ PacModelStatement::checkPass(ModFileStructure &mod_file_struct, WarningConsolida
 void
 PacModelStatement::overwriteGrowth(expr_t new_growth)
 {
-  if (new_growth == nullptr || growth == nullptr)
+  if (!new_growth || !growth)
     return;
 
   growth = new_growth;
@@ -402,8 +398,8 @@ VarEstimationStatement::VarEstimationStatement(OptionsList options_list_arg) :
 void
 VarEstimationStatement::checkPass(ModFileStructure &mod_file_struct, WarningConsolidation &warnings)
 {
-  auto it = options_list.string_options.find("var_estimation.model_name");
-  if (it == options_list.string_options.end())
+  if (auto it = options_list.string_options.find("var_estimation.model_name");
+      it == options_list.string_options.end())
     {
       cerr << "ERROR: You must provide the model name to the var_estimation statement." << endl;
       exit(EXIT_FAILURE);
@@ -441,8 +437,7 @@ VarRestrictionsStatement::findIdxInVector(const vector<string> &vecvars, const s
 {
   int idx = 0;
   bool setflag = false;
-  for (auto itvs = vecvars.begin();
-       itvs != vecvars.end(); itvs++, idx++)
+  for (auto itvs = vecvars.begin(); itvs != vecvars.end(); ++itvs, idx++)
     if (*itvs == var)
       {
         setflag = true;
@@ -476,13 +471,12 @@ VarRestrictionsStatement::writeOutput(ostream &output, const string &basename, b
   // Exclusion Restrictions
   int idx = 1;
   for (auto it = exclusion_restrictions.begin();
-       it != exclusion_restrictions.end(); it++, idx++)
+       it != exclusion_restrictions.end(); ++it, idx++)
     {
       output << Mstr << "exclusion_restrictions{" << idx<< "}.lag = "
              << it->first << ";" << endl
              << Mstr << "exclusion_restrictions{" << idx << "}.restrictions = [";
-      for (auto it1 = it->second.begin();
-           it1 != it->second.end(); it1++)
+      for (auto it1 = it->second.begin(); it1 != it->second.end(); ++it1)
         {
           if (it1 != it->second.begin())
             output << " ";
@@ -490,9 +484,8 @@ VarRestrictionsStatement::writeOutput(ostream &output, const string &basename, b
           output << "struct('eq', " << findIdxInVector(vars, symbol_table.getName(it1->first)) + 1
                  << ", 'vars', [";
           vector<string> excvars = it1->second.getSymbols();
-          for (vector<string>::const_iterator itvs1 = excvars.begin();
-               itvs1 != excvars.end(); itvs1++)
-            output << findIdxInVector(vars, *itvs1) + 1 << " ";
+          for (auto & excvar : excvars)
+            output << findIdxInVector(vars, excvar) + 1 << " ";
           output << "])";
           nrestrictions += it1->second.getSize();
         }
@@ -502,7 +495,7 @@ VarRestrictionsStatement::writeOutput(ostream &output, const string &basename, b
   // Equation Restrictions
   idx = 1;
   for (auto it = equation_restrictions.begin();
-       it != equation_restrictions.end(); it++, idx++, nrestrictions++)
+       it != equation_restrictions.end(); ++it, idx++, nrestrictions++)
     {
       output << Mstr << "equation_restriction{" << idx << "}.eq = '"
              << symbol_table.getName(it->first) << "';" << endl
@@ -534,7 +527,7 @@ VarRestrictionsStatement::writeOutput(ostream &output, const string &basename, b
   // Cross Equation Restrictions
   idx = 1;
   for (auto it = crossequation_restrictions.begin();
-       it != crossequation_restrictions.end(); it++, idx++, nrestrictions++)
+       it != crossequation_restrictions.end(); ++it, idx++, nrestrictions++)
     {
       output << Mstr << "crossequation_restriction{" << idx << "}.val = "
              << it->second << ";" << endl;
@@ -568,7 +561,7 @@ VarRestrictionsStatement::writeOutput(ostream &output, const string &basename, b
   // Covariance Const Restrictions
   idx = 1;
   for (auto it = covariance_number_restriction.begin();
-       it != covariance_number_restriction.end(); it++, idx++)
+       it != covariance_number_restriction.end(); ++it, idx++)
     output << Mstr << "covariance_const_restriction{" << idx << "}.var1 = '"
            << symbol_table.getName(it->first.first) << "';" << endl
            << Mstr << "covariance_const_restriction{" << idx << "}.var2 = '"
@@ -579,7 +572,7 @@ VarRestrictionsStatement::writeOutput(ostream &output, const string &basename, b
   // Covariance Pair Restrictions
   idx = 1;
   for (auto it = covariance_pair_restriction.begin();
-       it != covariance_pair_restriction.end(); it++, idx++)
+       it != covariance_pair_restriction.end(); ++it, idx++)
     output << Mstr << "covariance_pair_restriction{" << idx << "}.var11 = '"
            << symbol_table.getName(it->first.first) << "';" << endl
            << Mstr << "covariance_pair_restriction{" << idx << "}.var12 = '"
@@ -605,25 +598,25 @@ StochSimulStatement::checkPass(ModFileStructure &mod_file_struct, WarningConsoli
   mod_file_struct.stoch_simul_present = true;
 
   // Fill in option_order of mod_file_struct
-  auto it = options_list.num_options.find("order");
-  if (it != options_list.num_options.end())
+  if (auto it = options_list.num_options.find("order");
+      it != options_list.num_options.end())
     mod_file_struct.order_option = max(mod_file_struct.order_option, stoi(it->second));
 
   // Fill in mod_file_struct.partial_information
-  it = options_list.num_options.find("partial_information");
-  if (it != options_list.num_options.end() && it->second == "true")
+  if (auto it = options_list.num_options.find("partial_information");
+      it != options_list.num_options.end() && it->second == "true")
     mod_file_struct.partial_information = true;
 
   // Option k_order_solver (implicit when order >= 3)
-  it = options_list.num_options.find("k_order_solver");
-  if ((it != options_list.num_options.end() && it->second == "true")
+  if (auto it = options_list.num_options.find("k_order_solver");
+      (it != options_list.num_options.end() && it->second == "true")
       || mod_file_struct.order_option >= 3)
     mod_file_struct.k_order_solver = true;
 
-  it = options_list.num_options.find("hp_filter");
-  auto it1 = options_list.num_options.find("bandpass.indicator");
-  auto it2 = options_list.num_options.find("one_sided_hp_filter");
-  if ((it != options_list.num_options.end() && it1 != options_list.num_options.end())
+  if (auto it = options_list.num_options.find("hp_filter"),
+      it1 = options_list.num_options.find("bandpass.indicator"),
+      it2 = options_list.num_options.find("one_sided_hp_filter");
+      (it != options_list.num_options.end() && it1 != options_list.num_options.end())
       || (it != options_list.num_options.end() && it2 != options_list.num_options.end())
       || (it1 != options_list.num_options.end() && it2 != options_list.num_options.end()))
     {
@@ -639,9 +632,9 @@ void
 StochSimulStatement::writeOutput(ostream &output, const string &basename, bool minimal_workspace) const
 {
   // Ensure that order 3 implies k_order (#844)
-  auto it = options_list.num_options.find("order");
-  auto it1 = options_list.num_options.find("k_order_solver");
-  if ((it1 != options_list.num_options.end() && it1->second == "true")
+  if (auto it = options_list.num_options.find("order"),
+      it1 = options_list.num_options.find("k_order_solver");
+      (it1 != options_list.num_options.end() && it1->second == "true")
       || (it != options_list.num_options.end() && stoi(it->second) >= 3))
     output << "options_.k_order_solver = true;" << endl;
 
@@ -715,31 +708,31 @@ DetCondForecast::writeOutput(ostream &output, const string &basename, bool minim
   options_list.writeOutput(output);
   if (linear_decomposition)
     {
-      output << "first_order_solution_to_compute = 1;" << endl;
-      output << "if exist('oo_')" << endl;
-      output << "  if isfield(oo_, 'dr')" << endl;
-      output << "    if isfield(oo_.dr, 'ghx') && isfield(oo_.dr, 'ghu') && isfield(oo_.dr, 'state_var') && isfield(oo_.dr, 'order_var')" << endl;
-      output << "      first_order_solution_to_compute = 0;" << endl;
-      output << "    end;" << endl;
-      output << "  end;" << endl;
-      output << "end;" << endl;
-      output << "if first_order_solution_to_compute" << endl;
-      output << " fprintf('%s','Computing the first order solution ...');" << endl;
-      output << " options_.nograph = true;" << endl;
-      output << " options_.order = 1;" << endl;
-      output << " options_.noprint = true;" << endl;
-      output << " options_.nocorr = true;" << endl;
-      output << " options_.nomoments = true;" << endl;
-      output << " options_.nodecomposition = true;" << endl;
-      output << " options_.nofunctions = true;" << endl;
-      output << " options_.irf = 0;" << endl;
-      output << " tmp_periods = options_.periods;" << endl;
-      output << " options_.periods = 0;" << endl;
-      output << " var_list_ = char();" << endl;
-      output << " info = stoch_simul(var_list_);" << endl;
-      output << R"( fprintf('%s\n','done');)" << endl;
-      output << " options_.periods = tmp_periods;" << endl;
-      output << "end;" << endl;
+      output << "first_order_solution_to_compute = 1;" << endl
+             << "if exist('oo_')" << endl
+             << "  if isfield(oo_, 'dr')" << endl
+             << "    if isfield(oo_.dr, 'ghx') && isfield(oo_.dr, 'ghu') && isfield(oo_.dr, 'state_var') && isfield(oo_.dr, 'order_var')" << endl
+             << "      first_order_solution_to_compute = 0;" << endl
+             << "    end;" << endl
+             << "  end;" << endl
+             << "end;" << endl
+             << "if first_order_solution_to_compute" << endl
+             << "  fprintf('%s','Computing the first order solution ...');" << endl
+             << "  options_.nograph = true;" << endl
+             << "  options_.order = 1;" << endl
+             << "  options_.noprint = true;" << endl
+             << "  options_.nocorr = true;" << endl
+             << "  options_.nomoments = true;" << endl
+             << "  options_.nodecomposition = true;" << endl
+             << "  options_.nofunctions = true;" << endl
+             << "  options_.irf = 0;" << endl
+             << "  tmp_periods = options_.periods;" << endl
+             << "  options_.periods = 0;" << endl
+             << "  var_list_ = char();" << endl
+             << "  info = stoch_simul(var_list_);" << endl
+             << R"(  fprintf('%s\n','done');)" << endl
+             << "  options_.periods = tmp_periods;" << endl
+             << "end;" << endl;
     }
   vector<string> symbols = symbol_list.get_symbols();
   if (symbols.size() > 0)
@@ -801,9 +794,9 @@ RamseyModelStatement::writeOutput(ostream &output, const string &basename, bool
   // It should probably rather be a M_ field, but we leave it in options_ for historical reason
 
   // Ensure that order 3 implies k_order (#844)
-  auto it = options_list.num_options.find("order");
-  auto it1 = options_list.num_options.find("k_order_solver");
-  if ((it1 != options_list.num_options.end() && it1->second == "true")
+  if (auto it = options_list.num_options.find("order"),
+      it1 = options_list.num_options.find("k_order_solver");
+      (it1 != options_list.num_options.end() && it1->second == "true")
       || (it != options_list.num_options.end() && stoi(it->second) >= 3))
     output << "options_.k_order_solver = true;" << endl;
 
@@ -832,7 +825,7 @@ RamseyConstraintsStatement::RamseyConstraintsStatement(const SymbolTable &symbol
 void
 RamseyConstraintsStatement::checkPass(ModFileStructure &mod_file_struct, WarningConsolidation &warnings)
 {
-  if ((mod_file_struct.ramsey_model_present != true) || (mod_file_struct.ramsey_policy_present != true))
+  if (!mod_file_struct.ramsey_model_present || !mod_file_struct.ramsey_policy_present)
     cerr << "ramsey_constraints: can only be used with ramsey_model or ramsey_policy" << endl;
 }
 
@@ -896,7 +889,7 @@ RamseyConstraintsStatement::writeJsonOutput(ostream &output) const
           break;
         default:
           cerr << "Ramsey constraints: this shouldn't happen." << endl;
-          exit(1);
+          exit(EXIT_FAILURE);
         }
       output << " ";
       it->expression->writeJsonOutput(output, {}, {});
@@ -978,9 +971,9 @@ void
 RamseyPolicyStatement::writeOutput(ostream &output, const string &basename, bool minimal_workspace) const
 {
   // Ensure that order 3 implies k_order (#844)
-  auto it = options_list.num_options.find("order");
-  auto it1 = options_list.num_options.find("k_order_solver");
-  if ((it1 != options_list.num_options.end() && it1->second == "true")
+  if (auto it = options_list.num_options.find("order"),
+      it1 = options_list.num_options.find("k_order_solver");
+        (it1 != options_list.num_options.end() && it1->second == "true")
       || (it != options_list.num_options.end() && stoi(it->second) >= 3))
     output << "options_.k_order_solver = true;" << endl;
 
@@ -1018,10 +1011,6 @@ RamseyPolicyStatement::writeJsonOutput(ostream &output) const
          << "}";
 }
 
-EvaluatePlannerObjective::EvaluatePlannerObjective()
-{
-}
-
 void
 EvaluatePlannerObjective::writeOutput(ostream &output, const string &basename, bool minimal_workspace) const
 {
@@ -1088,9 +1077,9 @@ void
 DiscretionaryPolicyStatement::writeOutput(ostream &output, const string &basename, bool minimal_workspace) const
 {
   // Ensure that order 3 implies k_order (#844)
-  auto it = options_list.num_options.find("order");
-  auto it1 = options_list.num_options.find("k_order_solver");
-  if ((it1 != options_list.num_options.end() && it1->second == "true")
+  if (auto it = options_list.num_options.find("order"),
+      it1 = options_list.num_options.find("k_order_solver");
+      (it1 != options_list.num_options.end() && it1->second == "true")
       || (it != options_list.num_options.end() && stoi(it->second) >= 3))
     output << "options_.k_order_solver = true;" << endl;
 
@@ -1129,8 +1118,8 @@ EstimationStatement::checkPass(ModFileStructure &mod_file_struct, WarningConsoli
   mod_file_struct.estimation_present = true;
 
   // Fill in option_order of mod_file_struct
-  auto it = options_list.num_options.find("order");
-  if (it != options_list.num_options.end())
+  if (auto it = options_list.num_options.find("order");
+      it != options_list.num_options.end())
     {
       int order = stoi(it->second);
 
@@ -1144,32 +1133,30 @@ EstimationStatement::checkPass(ModFileStructure &mod_file_struct, WarningConsoli
     }
 
   // Fill in mod_file_struct.partial_information
-  it = options_list.num_options.find("partial_information");
-  if (it != options_list.num_options.end() && it->second == "true")
+  if (auto it = options_list.num_options.find("partial_information");
+      it != options_list.num_options.end() && it->second == "true")
     mod_file_struct.partial_information = true;
 
   // Fill in mod_file_struct.estimation_analytic_derivation
-  it = options_list.num_options.find("analytic_derivation");
-  if (it != options_list.num_options.end() && it->second == "1")
+  if (auto it = options_list.num_options.find("analytic_derivation");
+      it != options_list.num_options.end() && it->second == "1")
     mod_file_struct.estimation_analytic_derivation = true;
 
-  it = options_list.num_options.find("dsge_var");
-  if (it != options_list.num_options.end())
+  if (auto it = options_list.num_options.find("dsge_var");
+      it != options_list.num_options.end())
     // Fill in mod_file_struct.dsge_var_calibrated
     mod_file_struct.dsge_var_calibrated = it->second;
 
   // Fill in mod_file_struct.dsge_var_estimated
-  auto it_str = options_list.string_options.find("dsge_var");
-  if (it_str != options_list.string_options.end())
+  if (options_list.string_options.find("dsge_var") != options_list.string_options.end())
     mod_file_struct.dsge_var_estimated = true;
 
   // Fill in mod_file_struct.bayesian_irf_present
-  it = options_list.num_options.find("bayesian_irf");
-  if (it != options_list.num_options.end() && it->second == "true")
+  if (auto it = options_list.num_options.find("bayesian_irf");
+      it != options_list.num_options.end() && it->second == "true")
     mod_file_struct.bayesian_irf_present = true;
 
-  it = options_list.num_options.find("dsge_varlag");
-  if (it != options_list.num_options.end())
+  if (options_list.num_options.find("dsge_varlag") != options_list.num_options.end())
     if (mod_file_struct.dsge_var_calibrated.empty()
         && !mod_file_struct.dsge_var_estimated)
       {
@@ -1206,15 +1193,15 @@ EstimationStatement::writeOutput(ostream &output, const string &basename, bool m
   options_list.writeOutput(output);
 
   // Special treatment for order option and particle filter
-  auto it = options_list.num_options.find("order");
-  if (it == options_list.num_options.end())
+  if (auto it = options_list.num_options.find("order");
+      it == options_list.num_options.end())
     output << "options_.order = 1;" << endl;
   else if (stoi(it->second) == 2)
     output << "options_.particle.status = true;" << endl;
 
   // Do not check for the steady state in diffuse filter mode (#400)
-  it = options_list.num_options.find("diffuse_filter");
-  if (it != options_list.num_options.end() && it->second == "true")
+  if (auto it = options_list.num_options.find("diffuse_filter");
+      it != options_list.num_options.end() && it->second == "true")
     output << "options_.steadystate.nocheck = true;" << endl;
 
   symbol_list.writeOutput("var_list_", output);
@@ -1246,9 +1233,8 @@ DynareSensitivityStatement::DynareSensitivityStatement(OptionsList options_list_
 void
 DynareSensitivityStatement::checkPass(ModFileStructure &mod_file_struct, WarningConsolidation &warnings)
 {
-  auto it = options_list.num_options.find("identification");
-  if (it != options_list.num_options.end()
-      && it->second == "1")
+  if (auto it = options_list.num_options.find("identification");
+      it != options_list.num_options.end() && it->second == "1")
     mod_file_struct.identification_present = true;
   mod_file_struct.sensitivity_present = true;
 }
@@ -1262,15 +1248,15 @@ DynareSensitivityStatement::writeOutput(ostream &output, const string &basename,
      options_.
      \todo factorize this code between identification and dynare_sensitivity,
      and provide a generic mechanism for this situation (maybe using regexps) */
-  auto it = options_list.num_options.find("nodisplay");
-  if (it != options_list.num_options.end())
+  if (auto it = options_list.num_options.find("nodisplay");
+      it != options_list.num_options.end())
     output << "options_.nodisplay = " << it->second << ";" << endl;
-  it = options_list.num_options.find("nograph");
-  if (it != options_list.num_options.end())
+  if (auto it = options_list.num_options.find("nograph");
+      it != options_list.num_options.end())
     output << "options_.nograph = " << it->second << ";" << endl;
-  auto it2 = options_list.string_options.find("graph_format");
-  if (it2 != options_list.string_options.end())
-    output << "options_.graph_format = '" << it2->second << "';" << endl;
+  if (auto it = options_list.string_options.find("graph_format");
+      it != options_list.string_options.end())
+    output << "options_.graph_format = '" << it->second << "';" << endl;
 
   output << "dynare_sensitivity(options_gsa);" << endl;
 }
@@ -1497,7 +1483,7 @@ EstimatedParamsStatement::writeJsonOutput(ostream &output) const
 {
   output << R"({"statementName": "estimated_params", )"
          << R"("params": [)";
-  for (auto it = estim_params_list.begin(); it != estim_params_list.end(); it++)
+  for (auto it = estim_params_list.begin(); it != estim_params_list.end(); ++it)
     {
       if (it != estim_params_list.begin())
         output << ", ";
@@ -1653,7 +1639,7 @@ EstimatedParamsInitStatement::writeJsonOutput(ostream &output) const
     output << R"(, "use_calibration_initialization": 1)";
 
   output << R"(, "params": [)";
-  for (auto it = estim_params_list.begin(); it != estim_params_list.end(); it++)
+  for (auto it = estim_params_list.begin(); it != estim_params_list.end(); ++it)
     {
       if (it != estim_params_list.begin())
         output << ", ";
@@ -1771,7 +1757,7 @@ EstimatedParamsBoundsStatement::writeJsonOutput(ostream &output) const
   output << R"({"statementName": "estimated_params_bounds", )"
          << R"("params": [)";
 
-  for (auto it = estim_params_list.begin(); it != estim_params_list.end(); it++)
+  for (auto it = estim_params_list.begin(); it != estim_params_list.end(); ++it)
     {
       if (it != estim_params_list.begin())
         output << ", ";
@@ -1870,8 +1856,8 @@ OsrParamsStatement::writeOutput(ostream &output, const string &basename, bool mi
          << "M_.osr.param_indices = zeros(length(M_.osr.param_names), 1);" << endl;
   int i = 0;
   vector<string> symbols = symbol_list.get_symbols();
-  for (vector<string>::const_iterator it = symbols.begin(); it != symbols.end(); it++)
-    output << "M_.osr.param_indices(" << ++i <<") = " << symbol_table.getTypeSpecificID(*it) + 1 << ";" << endl;
+  for (auto & symbol : symbols)
+    output << "M_.osr.param_indices(" << ++i <<") = " << symbol_table.getTypeSpecificID(symbol) + 1 << ";" << endl;
 }
 
 void
@@ -1929,8 +1915,7 @@ OsrParamsBoundsStatement::writeJsonOutput(ostream &output) const
 {
   output << R"({"statementName": "osr_params_bounds")"
          << R"(, "bounds": [)";
-  for (auto it = osr_params_list.begin();
-       it != osr_params_list.end(); it++)
+  for (auto it = osr_params_list.begin(); it != osr_params_list.end(); ++it)
     {
       if (it != osr_params_list.begin())
         output << ", ";
@@ -1952,18 +1937,18 @@ OsrStatement::checkPass(ModFileStructure &mod_file_struct, WarningConsolidation
   mod_file_struct.osr_present = true;
 
   // Fill in option_order of mod_file_struct
-  auto it = options_list.num_options.find("order");
-  if (it != options_list.num_options.end())
+  if (auto it = options_list.num_options.find("order");
+      it != options_list.num_options.end())
     mod_file_struct.order_option = max(mod_file_struct.order_option, stoi(it->second));
 
   // Fill in mod_file_struct.partial_information
-  it = options_list.num_options.find("partial_information");
-  if (it != options_list.num_options.end() && it->second == "true")
+  if (auto it = options_list.num_options.find("partial_information");
+      it != options_list.num_options.end() && it->second == "true")
     mod_file_struct.partial_information = true;
 
   // Option k_order_solver (implicit when order >= 3)
-  it = options_list.num_options.find("k_order_solver");
-  if ((it != options_list.num_options.end() && it->second == "true")
+  if (auto it = options_list.num_options.find("k_order_solver");
+      (it != options_list.num_options.end() && it->second == "true")
       || mod_file_struct.order_option >= 3)
     mod_file_struct.k_order_solver = true;
 }
@@ -1972,9 +1957,9 @@ void
 OsrStatement::writeOutput(ostream &output, const string &basename, bool minimal_workspace) const
 {
   // Ensure that order 3 implies k_order (#844)
-  auto it = options_list.num_options.find("order");
-  auto it1 = options_list.num_options.find("k_order_solver");
-  if ((it1 != options_list.num_options.end() && it1->second == "true")
+  if (auto it = options_list.num_options.find("order"),
+      it1 = options_list.num_options.find("k_order_solver");
+      (it1 != options_list.num_options.end() && it1->second == "true")
       || (it != options_list.num_options.end() && stoi(it->second) >= 3))
     output << "options_.k_order_solver = true;" << endl;
 
@@ -2024,10 +2009,8 @@ OptimWeightsStatement::writeOutput(ostream &output, const string &basename, bool
          << "M_.osr.variable_weights = sparse(M_.endo_nbr,M_.endo_nbr);" << endl
          << "M_.osr.variable_indices = [];" << endl << endl;
 
-  for (const auto & var_weight : var_weights)
+  for (const auto & [name, value] : var_weights)
     {
-      const string &name = var_weight.first;
-      const expr_t value = var_weight.second;
       int id = symbol_table.getTypeSpecificID(name) + 1;
       output << "M_.osr.variable_weights(" << id << "," << id << ") = ";
       value->writeOutput(output);
@@ -2035,13 +2018,10 @@ OptimWeightsStatement::writeOutput(ostream &output, const string &basename, bool
       output << "M_.osr.variable_indices = [M_.osr.variable_indices; " << id << "];" << endl;
     }
 
-  for (const auto & covar_weight : covar_weights)
+  for (const auto & [names, value] : covar_weights)
     {
-      const string &name1 = covar_weight.first.first;
-      const string &name2 = covar_weight.first.second;
-      const expr_t value = covar_weight.second;
-      int id1 = symbol_table.getTypeSpecificID(name1) + 1;
-      int id2 = symbol_table.getTypeSpecificID(name2) + 1;
+      int id1 = symbol_table.getTypeSpecificID(names.first) + 1;
+      int id2 = symbol_table.getTypeSpecificID(names.second) + 1;
       output << "M_.osr.variable_weights(" << id1 << "," << id2 << ") = ";
       value->writeOutput(output);
       output << ";" << endl;
@@ -2054,8 +2034,7 @@ OptimWeightsStatement::writeJsonOutput(ostream &output) const
 {
   output << R"({"statementName": "optim_weights", )"
          << R"("weights": [)";
-  for (auto it = var_weights.begin();
-       it != var_weights.end(); it++)
+  for (auto it = var_weights.begin(); it != var_weights.end(); ++it)
     {
       if (it != var_weights.begin())
         output << ", ";
@@ -2065,8 +2044,7 @@ OptimWeightsStatement::writeJsonOutput(ostream &output) const
       output << R"("})";
     }
 
-  for (auto it = covar_weights.begin();
-       it != covar_weights.end(); it++)
+  for (auto it = covar_weights.begin(); it != covar_weights.end(); ++it)
     {
       if (it != covar_weights.begin() || !var_weights.empty())
         output << ", ";
@@ -2166,8 +2144,7 @@ ModelComparisonStatement::writeJsonOutput(ostream &output) const
   if (!filename_list.empty())
     output << R"(, "filename_list": {)";
 
-  for (auto it = filename_list.begin();
-       it != filename_list.end(); it++)
+  for (auto it = filename_list.begin(); it != filename_list.end(); ++it)
     {
       if (it != filename_list.begin())
         output << ", ";
@@ -2389,12 +2366,10 @@ MSSBVARSimulationStatement::writeOutput(ostream &output, const string &basename,
   options_list.writeOutput(output);
 
   // Redeclare drop option if necessary
-  auto mh_replic_it = options_list.num_options.find("ms.mh_replic");
-  auto thinning_factor_it = options_list.num_options.find("ms.thinning_factor");
-  auto drop_it = options_list.num_options.find("ms.drop");
-  if (mh_replic_it != options_list.num_options.end() || thinning_factor_it != options_list.num_options.end())
-    if (drop_it == options_list.num_options.end())
-      output << "options_.ms.drop = 0.1*options_.ms.mh_replic*options_.ms.thinning_factor;" << endl;
+  if ((options_list.num_options.find("ms.mh_replic") != options_list.num_options.end()
+       || options_list.num_options.find("ms.thinning_factor") != options_list.num_options.end())
+      && (options_list.num_options.find("ms.drop") == options_list.num_options.end()))
+    output << "options_.ms.drop = 0.1*options_.ms.mh_replic*options_.ms.thinning_factor;" << endl;
 
   output << "[options_, oo_] = ms_simulation(M_, options_, oo_);" << endl;
 }
@@ -2452,13 +2427,13 @@ MSSBVARComputeProbabilitiesStatement::checkPass(ModFileStructure &mod_file_struc
 {
   mod_file_struct.bvar_present = true;
 
-  if (options_list.num_options.find("ms.real_time_smoothed_probabilities") != options_list.num_options.end())
-    if (options_list.num_options.find("ms.filtered_probabilities") != options_list.num_options.end())
-      {
-        cerr << "ERROR: You may only pass one of real_time_smoothed "
-             << "and filtered_probabilities to ms_compute_probabilities." << endl;
-        exit(EXIT_FAILURE);
-      }
+  if (options_list.num_options.find("ms.real_time_smoothed_probabilities") != options_list.num_options.end()
+      && options_list.num_options.find("ms.filtered_probabilities") != options_list.num_options.end())
+    {
+      cerr << "ERROR: You may only pass one of real_time_smoothed "
+           << "and filtered_probabilities to ms_compute_probabilities." << endl;
+      exit(EXIT_FAILURE);
+    }
 }
 
 void
@@ -2493,21 +2468,9 @@ MSSBVARIrfStatement::checkPass(ModFileStructure &mod_file_struct, WarningConsoli
 {
   mod_file_struct.bvar_present = true;
 
-  bool regime_present = false;
-  bool regimes_present = false;
-  bool filtered_probabilities_present = false;
-
-  auto it = options_list.num_options.find("ms.regimes");
-  if (it != options_list.num_options.end())
-    regimes_present = true;
-
-  it = options_list.num_options.find("ms.regime");
-  if (it != options_list.num_options.end())
-    regime_present = true;
-
-  it = options_list.num_options.find("ms.filtered_probabilities");
-  if (it != options_list.num_options.end())
-    filtered_probabilities_present = true;
+  bool regime_present = options_list.num_options.find("ms.regime") != options_list.num_options.end();
+  bool regimes_present = options_list.num_options.find("ms.regimes") != options_list.num_options.end();
+  bool filtered_probabilities_present = options_list.num_options.find("ms.filtered_probabilities") != options_list.num_options.end();
 
   if ((filtered_probabilities_present && regime_present)
       || (filtered_probabilities_present && regimes_present)
@@ -2555,12 +2518,12 @@ MSSBVARForecastStatement::checkPass(ModFileStructure &mod_file_struct, WarningCo
 {
   mod_file_struct.bvar_present = true;
 
-  if (options_list.num_options.find("ms.regimes") != options_list.num_options.end())
-    if (options_list.num_options.find("ms.regime") != options_list.num_options.end())
-      {
-        cerr << "ERROR: You may only pass one of regime and regimes to ms_forecast" << endl;
-        exit(EXIT_FAILURE);
-      }
+  if (options_list.num_options.find("ms.regimes") != options_list.num_options.end()
+      && options_list.num_options.find("ms.regime") != options_list.num_options.end())
+    {
+      cerr << "ERROR: You may only pass one of regime and regimes to ms_forecast" << endl;
+      exit(EXIT_FAILURE);
+    }
 }
 
 void
@@ -2593,21 +2556,9 @@ MSSBVARVarianceDecompositionStatement::checkPass(ModFileStructure &mod_file_stru
 {
   mod_file_struct.bvar_present = true;
 
-  bool regime_present = false;
-  bool regimes_present = false;
-  bool filtered_probabilities_present = false;
-
-  auto it = options_list.num_options.find("ms.regimes");
-  if (it != options_list.num_options.end())
-    regimes_present = true;
-
-  it = options_list.num_options.find("ms.regime");
-  if (it != options_list.num_options.end())
-    regime_present = true;
-
-  it = options_list.num_options.find("ms.filtered_probabilities");
-  if (it != options_list.num_options.end())
-    filtered_probabilities_present = true;
+  bool regime_present = options_list.num_options.find("ms.regime") != options_list.num_options.end();
+  bool regimes_present = options_list.num_options.find("ms.regimes") != options_list.num_options.end();
+  bool filtered_probabilities_present = options_list.num_options.find("ms.filtered_probabilities") != options_list.num_options.end();
 
   if ((filtered_probabilities_present && regime_present)
       || (filtered_probabilities_present && regimes_present)
@@ -2642,20 +2593,21 @@ MSSBVARVarianceDecompositionStatement::writeJsonOutput(ostream &output) const
 IdentificationStatement::IdentificationStatement(OptionsList options_list_arg)
   : options_list{move(options_list_arg)}
 {
-  if (options_list.num_options.find("max_dim_cova_group") != options_list.num_options.end())
-    if (stoi(options_list.num_options["max_dim_cova_group"]) == 0)
-      {
-        cerr << "ERROR: The max_dim_cova_group option to identification only accepts integers > 0." << endl;
-        exit(EXIT_FAILURE);
-      }
+  if (auto it = options_list.num_options.find("max_dim_cova_group");
+      it != options_list.num_options.end() && stoi(it->second) == 0)
+    {
+      cerr << "ERROR: The max_dim_cova_group option to identification only accepts integers > 0." << endl;
+      exit(EXIT_FAILURE);
+    }
 }
 
 void
 IdentificationStatement::checkPass(ModFileStructure &mod_file_struct, WarningConsolidation &warnings)
 {
   mod_file_struct.identification_present = true;
-  auto it = options_list.num_options.find("order");
-  if (it != options_list.num_options.end())
+
+  if (auto it = options_list.num_options.find("order");
+      it != options_list.num_options.end())
     {
       int order = stoi(it->second);
       if (order < 1 || order > 3)
@@ -2665,7 +2617,6 @@ IdentificationStatement::checkPass(ModFileStructure &mod_file_struct, WarningCon
           exit(EXIT_FAILURE);
         }
       mod_file_struct.identification_order = max(mod_file_struct.identification_order, order);
-
     }
   else
     // The default value for order is 1 (which triggers 2nd order dynamic derivatives)
@@ -2681,15 +2632,15 @@ IdentificationStatement::writeOutput(ostream &output, const string &basename, bo
      options_.
      \todo factorize this code between identification and dynare_sensitivity,
      and provide a generic mechanism for this situation (maybe using regexps) */
-  auto it = options_list.num_options.find("nodisplay");
-  if (it != options_list.num_options.end())
+  if (auto it = options_list.num_options.find("nodisplay");
+      it != options_list.num_options.end())
     output << "options_.nodisplay = " << it->second << ";" << endl;
-  it = options_list.num_options.find("nograph");
-  if (it != options_list.num_options.end())
+  if (auto it = options_list.num_options.find("nograph");
+      it != options_list.num_options.end())
     output << "options_.nograph = " << it->second << ";" << endl;
-  auto it2 = options_list.string_options.find("graph_format");
-  if (it2 != options_list.string_options.end())
-    output << "options_.graph_format = '" << it2->second << "';" << endl;
+  if (auto it = options_list.string_options.find("graph_format");
+      it != options_list.string_options.end())
+    output << "options_.graph_format = '" << it->second << "';" << endl;
 
   output << "dynare_identification(options_ident);" << endl;
 }
@@ -3060,26 +3011,26 @@ SvarIdentificationStatement::writeOutput(ostream &output, const string &basename
                << "error in the specification of the .mod file, please report it to the Dynare Team." << endl;
           exit(EXIT_FAILURE);
         }
-      output << "options_.ms.Qi = cell(" << n << ",1);" << endl;
-      output << "options_.ms.Ri = cell(" << n << ",1);" << endl;
+      output << "options_.ms.Qi = cell(" << n << ",1);" << endl
+             << "options_.ms.Ri = cell(" << n << ",1);" << endl;
 
-      for (auto it = restrictions.begin(); it != restrictions.end(); it++)
+      for (auto &it : restrictions)
         {
-          assert(it->lag >= 0);
-          if (it->lag == 0)
-            output << "options_.ms.Qi{" << it->equation << "}(" << it->restriction_nbr << ", " << it->variable + 1 << ") = ";
+          assert(it.lag >= 0);
+          if (it.lag == 0)
+            output << "options_.ms.Qi{" << it.equation << "}(" << it.restriction_nbr << ", " << it.variable + 1 << ") = ";
           else
             {
-              int col = (it->lag-1)*n+it->variable+1;
+              int col = (it.lag-1)*n+it.variable+1;
               if (col > k)
                 {
-                  cerr << "ERROR: lag =" << it->lag << ", num endog vars = " << n << "current endog var index = " << it->variable << ". Index "
+                  cerr << "ERROR: lag =" << it.lag << ", num endog vars = " << n << "current endog var index = " << it.variable << ". Index "
                        << "out of bounds. If the above does not represent a logical error, please report this to the Dynare Team." << endl;
                   exit(EXIT_FAILURE);
                 }
-              output << "options_.ms.Ri{" << it->equation << "}(" << it->restriction_nbr << ", " << col << ") = ";
+              output << "options_.ms.Ri{" << it.equation << "}(" << it.restriction_nbr << ", " << col << ") = ";
             }
-          it->value->writeOutput(output);
+          it.value->writeOutput(output);
           output << ";" << endl;
         }
       output << "options_.ms.nlags = " << r << ";" << endl;
@@ -3105,7 +3056,7 @@ SvarIdentificationStatement::writeJsonOutput(ostream &output) const
       output << R"(, "nlags": )" << getMaxLag()
              << R"(, "restrictions": [)";
 
-      for (auto it = restrictions.begin(); it != restrictions.end(); it++)
+      for (auto it = restrictions.begin(); it != restrictions.end(); ++it)
         {
           if (it != restrictions.begin())
             output << ", ";
@@ -3125,12 +3076,11 @@ SvarIdentificationStatement::writeJsonOutput(ostream &output) const
 MarkovSwitchingStatement::MarkovSwitchingStatement(OptionsList options_list_arg) :
   options_list{move(options_list_arg)}
 {
-  auto it_num = options_list.num_options.find("ms.restrictions");
-  if (it_num != options_list.num_options.end())
+  if (auto it_num = options_list.num_options.find("ms.restrictions");
+      it_num != options_list.num_options.end())
     {
       using namespace boost;
-      auto it_num_regimes
-        = options_list.num_options.find("ms.number_of_regimes");
+      auto it_num_regimes = options_list.num_options.find("ms.number_of_regimes");
       assert(it_num_regimes !=  options_list.num_options.end());
       auto num_regimes = stoi(it_num_regimes->second);
 
@@ -3141,12 +3091,11 @@ MarkovSwitchingStatement::MarkovSwitchingStatement(OptionsList options_list_arg)
           {
             vector<string> restriction;
             split(restriction, tokenizedRestriction, is_any_of("], "));
-            for (auto it1 = restriction.begin();
-                 it1 != restriction.end();)
+            for (auto it1 = restriction.begin(); it1 != restriction.end();)
               if (it1->empty())
                 restriction.erase(it1);
               else
-                it1++;
+                ++it1;
 
             if (restriction.size() != 3)
               {
@@ -3207,12 +3156,11 @@ MarkovSwitchingStatement::checkPass(ModFileStructure &mod_file_struct, WarningCo
       exit(EXIT_FAILURE);
     }
 
-  auto it_num = options_list.num_options.find("ms.restrictions");
-  if (it_num != options_list.num_options.end())
+  if (auto it_num = options_list.num_options.find("ms.restrictions");
+      it_num != options_list.num_options.end())
     {
       using namespace boost;
-      auto it_num_regimes
-        = options_list.num_options.find("ms.number_of_regimes");
+      auto it_num_regimes = options_list.num_options.find("ms.number_of_regimes");
       assert(it_num_regimes != options_list.num_options.end());
       auto num_regimes = stoi(it_num_regimes->second);
       vector<double> col_trans_prob_sum(num_regimes, 0);
@@ -3321,8 +3269,7 @@ MarkovSwitchingStatement::writeJsonOutput(ostream &output) const
 
   if (!restriction_map.empty())
     output << ", {";
-  for (auto it = restriction_map.begin();
-       it != restriction_map.end(); it++)
+  for (auto it = restriction_map.begin(); it != restriction_map.end(); ++it)
     {
       if (it != restriction_map.begin())
         output << ", ";
@@ -3344,10 +3291,9 @@ SvarStatement::SvarStatement(OptionsList options_list_arg) :
 void
 SvarStatement::checkPass(ModFileStructure &mod_file_struct, WarningConsolidation &warnings)
 {
-  OptionsList::num_options_t::const_iterator it0, it1, it2;
-  it0 = options_list.string_options.find("ms.coefficients");
-  it1 = options_list.string_options.find("ms.variances");
-  it2 = options_list.string_options.find("ms.constants");
+  auto it0 = options_list.string_options.find("ms.coefficients"),
+    it1 = options_list.string_options.find("ms.variances"),
+    it2 = options_list.string_options.find("ms.constants");
   assert((it0 != options_list.string_options.end()
           && it1 == options_list.string_options.end()
           && it2 == options_list.string_options.end())
@@ -3362,27 +3308,22 @@ SvarStatement::checkPass(ModFileStructure &mod_file_struct, WarningConsolidation
 void
 SvarStatement::writeOutput(ostream &output, const string &basename, bool minimal_workspace) const
 {
-  OptionsList::num_options_t::const_iterator it0, it1, it2;
-  OptionsList::vec_int_options_t::const_iterator itv;
+  auto it = options_list.num_options.find("ms.chain");
+  assert(it != options_list.num_options.end());
+  output << "options_.ms.ms_chain(" << it->second << ")";
 
-  it0 = options_list.num_options.find("ms.chain");
-  assert(it0 != options_list.num_options.end());
-  output << "options_.ms.ms_chain(" << it0->second << ")";
-
-  it0 = options_list.string_options.find("ms.coefficients");
-  it1 = options_list.string_options.find("ms.variances");
-  it2 = options_list.string_options.find("ms.constants");
-
-  if (it0 != options_list.string_options.end())
+  if (auto it0 = options_list.string_options.find("ms.coefficients");
+      it0 != options_list.string_options.end())
     output << "." << it0->second;
-  else if (it1 != options_list.string_options.end())
+  else if (auto it1 = options_list.string_options.find("ms.variances");
+           it1 != options_list.string_options.end())
     output << "." << it1->second;
   else
-    output << "." << it2->second;
+    output << "." << options_list.string_options.find("ms.constants")->second;
 
-  itv = options_list.vector_int_options.find("ms.equations");
   output << ".equations = ";
-  if (itv != options_list.vector_int_options.end())
+  if (auto itv = options_list.vector_int_options.find("ms.equations");
+      itv != options_list.vector_int_options.end())
     {
       assert(itv->second.size() >= 1);
       if (itv->second.size() > 1)
@@ -3456,23 +3397,23 @@ EstimationDataStatement::checkPass(ModFileStructure &mod_file_struct, WarningCon
 {
   mod_file_struct.estimation_data_statement_present = true;
 
-  auto it = options_list.num_options.find("nobs");
-  if (it != options_list.num_options.end())
+  if (auto it = options_list.num_options.find("nobs");
+      it != options_list.num_options.end())
     if (stoi(it->second) <= 0)
       {
         cerr << "ERROR: The nobs option of the data statement only accepts positive integers." << endl;
         exit(EXIT_FAILURE);
       }
 
-  if ((options_list.string_options.find("file") == options_list.string_options.end())
-      && (options_list.string_options.find("series") == options_list.string_options.end()))
+  if (options_list.string_options.find("file") == options_list.string_options.end()
+      && options_list.string_options.find("series") == options_list.string_options.end())
     {
       cerr << "ERROR: The file or series option must be passed to the data statement." << endl;
       exit(EXIT_FAILURE);
     }
 
-  if ((options_list.string_options.find("file") != options_list.string_options.end())
-      && (options_list.string_options.find("series") != options_list.string_options.end()))
+  if (options_list.string_options.find("file") != options_list.string_options.end()
+      && options_list.string_options.find("series") != options_list.string_options.end())
     {
       cerr << "ERROR: The file and series options cannot be used simultaneously in the data statement." << endl;
       exit(EXIT_FAILURE);
@@ -3527,7 +3468,7 @@ SubsamplesStatement::writeOutput(ostream &output, const string &basename, bool m
 
   int map_indx = 1;
   for (auto it = subsample_declaration_map.begin();
-       it != subsample_declaration_map.end(); it++, map_indx++)
+       it != subsample_declaration_map.end(); ++it, map_indx++)
     output << "estimation_info.subsamples(subsamples_indx).range_index(" << map_indx << ") = {'"
            << it->first << "'};" << endl
            << "estimation_info.subsamples(subsamples_indx).range(" << map_indx << ").date1 = "
@@ -3580,7 +3521,7 @@ SubsamplesStatement::writeJsonOutput(ostream &output) const
 
   output << R"(, "declarations": {)";
   for (auto it = subsample_declaration_map.begin();
-       it != subsample_declaration_map.end(); it++)
+       it != subsample_declaration_map.end(); ++it)
     {
       if (it != subsample_declaration_map.begin())
         output << ",";
@@ -3700,8 +3641,8 @@ JointPriorStatement::checkPass(ModFileStructure &mod_file_struct, WarningConsoli
       exit(EXIT_FAILURE);
     }
 
-  auto it_num = options_list.num_options.find("domain");
-  if (it_num != options_list.num_options.end())
+  if (auto it_num = options_list.num_options.find("domain");
+      it_num != options_list.num_options.end())
     {
       using namespace boost;
       vector<string> tokenizedDomain;
@@ -3762,11 +3703,11 @@ JointPriorStatement::writeOutput(ostream &output, const string &basename, bool m
 void
 JointPriorStatement::writeOutputHelper(ostream &output, const string &field, const string &lhs_field) const
 {
-  auto itn = options_list.num_options.find(field);
   output << lhs_field << "." << field << " = {";
   if (field == "variance")
     output << "{";
-  if (itn != options_list.num_options.end())
+  if (auto itn = options_list.num_options.find(field);
+      itn != options_list.num_options.end())
     output << itn->second;
   else
     output << "{}";
@@ -3780,7 +3721,7 @@ JointPriorStatement::writeJsonOutput(ostream &output) const
 {
   output << R"({"statementName": "joint_prior")"
          << R"(, "key": [)";
-  for (auto it = joint_parameters.begin(); it != joint_parameters.end(); it++)
+  for (auto it = joint_parameters.begin(); it != joint_parameters.end(); ++it)
     {
       if (it != joint_parameters.begin())
         output << ", ";
@@ -3857,16 +3798,16 @@ BasicPriorStatement::checkPass(ModFileStructure &mod_file_struct, WarningConsoli
       exit(EXIT_FAILURE);
     }
 
-  auto it_stdev = options_list.num_options.find("stdev");
-  if ((it_stdev == options_list.num_options.end() && variance == nullptr)
-      || (it_stdev != options_list.num_options.end() && variance != nullptr))
+  if (auto it_stdev = options_list.num_options.find("stdev");
+      (it_stdev == options_list.num_options.end() && !variance)
+      || (it_stdev != options_list.num_options.end() && variance))
     {
       cerr << "ERROR: You must pass exactly one of stdev and variance to the prior statement." << endl;
       exit(EXIT_FAILURE);
     }
 
-  auto it_num = options_list.num_options.find("domain");
-  if (it_num != options_list.num_options.end())
+  if (auto it_num = options_list.num_options.find("domain");
+      it_num != options_list.num_options.end())
     {
       using namespace boost;
       vector<string> tokenizedDomain;
@@ -3925,8 +3866,8 @@ BasicPriorStatement::writeCommonOutput(ostream &output, const string &lhs_field)
 void
 BasicPriorStatement::writeCommonOutputHelper(ostream &output, const string &field, const string &lhs_field) const
 {
-  auto itn = options_list.num_options.find(field);
-  if (itn != options_list.num_options.end())
+  if (auto itn = options_list.num_options.find(field);
+      itn != options_list.num_options.end())
     output << lhs_field << "." << field << " = "<< itn->second << ";" << endl;
 }
 
@@ -3951,7 +3892,7 @@ BasicPriorStatement::writeJsonPriorOutput(ostream &output) const
          << R"(, "subsample": ")" << subsample_name << R"(")"
          << ", ";
   writeJsonShape(output);
-  if (variance != nullptr)
+  if (variance)
     {
       output << R"(, "variance": ")";
       variance->writeJsonOutput(output, {}, {});
@@ -4241,9 +4182,7 @@ BasicOptionsStatement::checkPass(ModFileStructure &mod_file_struct, WarningConso
 bool
 BasicOptionsStatement::is_structural_innovation(const SymbolType symb_type) const
 {
-  if (symb_type == SymbolType::exogenous || symb_type == SymbolType::exogenousDet)
-    return true;
-  return false;
+  return symb_type == SymbolType::exogenous || symb_type == SymbolType::exogenousDet;
 }
 
 void
@@ -4268,8 +4207,8 @@ BasicOptionsStatement::writeCommonOutput(ostream &output, const string &lhs_fiel
 void
 BasicOptionsStatement::writeCommonOutputHelper(ostream &output, const string &field, const string &lhs_field) const
 {
-  auto itn = options_list.num_options.find(field);
-  if (itn != options_list.num_options.end())
+  if (auto itn = options_list.num_options.find(field);
+      itn != options_list.num_options.end())
     output << lhs_field << "." << field << " = " << itn->second << ";" << endl;
 }
 
@@ -4534,8 +4473,7 @@ void
 CalibSmootherStatement::writeOutput(ostream &output, const string &basename, bool minimal_workspace) const
 {
   options_list.writeOutput(output);
-  auto it = options_list.string_options.find("parameter_set");
-  if (it == options_list.string_options.end())
+  if (options_list.string_options.find("parameter_set") == options_list.string_options.end())
     output << "options_.parameter_set = 'calibration';" << endl;
   symbol_list.writeOutput("var_list_", output);
   output << "options_.smoother = true;" << endl
@@ -4577,8 +4515,7 @@ ExtendedPathStatement::checkPass(ModFileStructure &mod_file_struct, WarningConso
     }
 
   // Fill in option_occbin of mod_file_struct
-  auto it = options_list.num_options.find("occbin");
-  if (it != options_list.string_options.end())
+  if (options_list.num_options.find("occbin") != options_list.string_options.end())
     mod_file_struct.occbin_option = true;
 }
 
@@ -4588,7 +4525,7 @@ ExtendedPathStatement::writeOutput(ostream &output, const string &basename, bool
   // Beware: options do not have the same name in the interface and in the M code...
 
   for (const auto & num_option : options_list.num_options)
-    if (num_option.first != string("periods"))
+    if (num_option.first != "periods")
       output << "options_." << num_option.first << " = " << num_option.second << ";" << endl;
 
   output << "extended_path([], " << options_list.num_options.find("periods")->second
@@ -4737,11 +4674,10 @@ GenerateIRFsStatement::writeOutput(ostream &output, const string &basename, bool
   for (size_t i = 0; i < generate_irf_names.size(); i++)
     {
       map<string, double> m = generate_irf_elements[i];
-      for (map<string, double>::const_iterator it = m.begin();
-         it != m.end(); it++)
+      for (auto & it : m)
         output << "options_.irf_opt.irf_shocks(M_.exo_names == '"
-               << it->first << "', " << i + 1 << ") = "
-               << it->second << ";" << endl;
+               << it.first << "', " << i + 1 << ") = "
+               << it.second << ";" << endl;
     }
 }
 
@@ -4763,8 +4699,7 @@ GenerateIRFsStatement::writeJsonOutput(ostream &output) const
           output << R"({"name": ")" << generate_irf_names[i] << R"(", "shocks": [)";
           map<string, double> m = generate_irf_elements[i];
           size_t idx = 0;
-          for (map<string, double>::const_iterator it = m.begin();
-               it != m.end(); it++, idx++)
+          for (auto it = m.begin(); it != m.end(); ++it, idx++)
             {
               output << R"({"exogenous_variable": ")" << it->first << R"(", )"
                      << R"("exogenous_variable_value": ")" << it->second << R"("})";
@@ -4871,8 +4806,8 @@ VarExpectationModelStatement::writeOutput(ostream &output, const string &basenam
          << mstruct << ".expr.params = [ " << params_list.str() << " ];" << endl
          << mstruct << ".expr.constants = [ " << constants_list.str() << " ];" << endl;
 
-  auto disc_var = dynamic_cast<const VariableNode *>(discount);
-  if (disc_var)
+  if (auto disc_var = dynamic_cast<const VariableNode *>(discount);
+      disc_var)
     output << mstruct << ".discount_index = " << symbol_table.getTypeSpecificID(disc_var->symb_id) + 1 << ';' << endl;
   else
     {
diff --git a/src/ComputingTasks.hh b/src/ComputingTasks.hh
index 31558a37421817514e61b945472eeca1362de6ef..bf898c179dbc8f7783c5608e1f8660642e9ff0c6 100644
--- a/src/ComputingTasks.hh
+++ b/src/ComputingTasks.hh
@@ -257,7 +257,6 @@ public:
 class EvaluatePlannerObjective : public Statement
 {
 public:
-  EvaluatePlannerObjective();
   void writeOutput(ostream &output, const string &basename, bool minimal_workspace) const override;
   void writeJsonOutput(ostream &output) const override;
 };
@@ -532,7 +531,7 @@ private:
   StaticModel model_tree;
   bool computing_pass_called{false};
 public:
-  PlannerObjectiveStatement(const StaticModel &model_tree_arg);
+  explicit PlannerObjectiveStatement(const StaticModel &model_tree_arg);
   /*! \todo check there are only endogenous variables at the current period in the objective
     (no exogenous, no lead/lag) */
   void checkPass(ModFileStructure &mod_file_struct, WarningConsolidation &warnings) override;
@@ -824,9 +823,7 @@ public:
   using svar_identification_restrictions_t = vector<svar_identification_restriction>;
 private:
   const svar_identification_restrictions_t restrictions;
-  const bool upper_cholesky_present;
-  const bool lower_cholesky_present;
-  const bool constants_exclusion_present;
+  const bool upper_cholesky_present, lower_cholesky_present, constants_exclusion_present;
   const SymbolTable &symbol_table;
   int getMaxLag() const;
 public:
@@ -844,7 +841,7 @@ class MarkovSwitchingStatement : public Statement
 {
 private:
   const OptionsList options_list;
-  map <pair<int, int >, double > restriction_map;
+  map<pair<int, int>, double> restriction_map;
 public:
   explicit MarkovSwitchingStatement(OptionsList options_list_arg);
   void checkPass(ModFileStructure &mod_file_struct, WarningConsolidation &warnings) override;
@@ -897,8 +894,7 @@ public:
   //! Storage for declaring subsamples: map<subsample_name, <date1, date2 >
   using subsample_declaration_map_t = map<string, pair<string, string>>;
 private:
-  const string name1;
-  const string name2;
+  const string name1, name2;
   const subsample_declaration_map_t subsample_declaration_map;
   const SymbolTable &symbol_table;
 public:
@@ -914,10 +910,7 @@ public:
 class SubsamplesEqualStatement : public Statement
 {
 private:
-  const string to_name1;
-  const string to_name2;
-  const string from_name1;
-  const string from_name2;
+  const string to_name1, to_name2, from_name1, from_name2;
   const SymbolTable &symbol_table;
 public:
   SubsamplesEqualStatement(string to_name1_arg,
@@ -948,8 +941,7 @@ public:
 class BasicPriorStatement : public Statement
 {
 protected:
-  const string name;
-  const string subsample_name;
+  const string name, subsample_name;
   const PriorDistributions prior_shape;
   const expr_t variance;
   const OptionsList options_list;
@@ -1020,14 +1012,8 @@ public:
 class PriorEqualStatement : public Statement
 {
 private:
-  const string to_declaration_type;
-  const string to_name1;
-  const string to_name2;
-  const string to_subsample_name;
-  const string from_declaration_type;
-  const string from_name1;
-  const string from_name2;
-  const string from_subsample_name;
+  const string to_declaration_type, to_name1, to_name2, to_subsample_name;
+  const string from_declaration_type, from_name1, from_name2, from_subsample_name;
   const SymbolTable &symbol_table;
 public:
   PriorEqualStatement(string to_declaration_type_arg,
@@ -1048,8 +1034,7 @@ public:
 class BasicOptionsStatement : public Statement
 {
 protected:
-  const string name;
-  const string subsample_name;
+  const string name, subsample_name;
   const OptionsList options_list;
   BasicOptionsStatement(string name_arg,
                         string subsample_name_arg,
@@ -1104,14 +1089,8 @@ public:
 class OptionsEqualStatement : public Statement
 {
 private:
-  const string to_declaration_type;
-  const string to_name1;
-  const string to_name2;
-  const string to_subsample_name;
-  const string from_declaration_type;
-  const string from_name1;
-  const string from_name2;
-  const string from_subsample_name;
+  const string to_declaration_type, to_name1, to_name2, to_subsample_name;
+  const string from_declaration_type, from_name1, from_name2, from_subsample_name;
   const SymbolTable &symbol_table;
 public:
   OptionsEqualStatement(string to_declaration_type_arg,
diff --git a/src/ConfigFile.cc b/src/ConfigFile.cc
index d1b2d314b0d74cf84fd1185968461a7a946438dd..6165a0c0c0fa9cd5c1d7f2f64b44c077a44e933e 100644
--- a/src/ConfigFile.cc
+++ b/src/ConfigFile.cc
@@ -176,10 +176,7 @@ ConfigFile::getConfigFileInfo(const string &config_file)
   bool singleCompThread{false};
   member_nodes_t member_nodes;
 
-  bool inHooks{false};
-  bool inNode{false};
-  bool inCluster{false};
-  bool inPaths{false};
+  bool inHooks{false}, inNode{false}, inCluster{false}, inPaths{false};
 
   while (configFile.good())
     {
@@ -666,11 +663,7 @@ ConfigFile::transformPass()
       }
 #endif
 
-  map<string, Cluster>::iterator cluster_it;
-  if (cluster_name.empty())
-    cluster_it = clusters.find(firstClusterName);
-  else
-    cluster_it = clusters.find(cluster_name);
+  auto cluster_it = cluster_name.empty() ? clusters.find(firstClusterName) : clusters.find(cluster_name);
 
   double weight_denominator{0.0};
   for (const auto & it : cluster_it->second.member_nodes)
@@ -687,7 +680,7 @@ ConfigFile::getIncludePaths() const
   for (auto path : paths)
     for (const auto & mapit : path.get_paths())
       for (const auto & vecit : mapit.second)
-        include_paths.push_back(vecit);
+        include_paths.emplace_back(vecit);
   return include_paths;
 }
 
@@ -705,11 +698,7 @@ ConfigFile::writeCluster(ostream &output) const
   if (!parallel && !parallel_test)
     return;
 
-  map<string, Cluster>::const_iterator cluster_it;
-  if (cluster_name.empty())
-    cluster_it = clusters.find(firstClusterName);
-  else
-    cluster_it = clusters.find(cluster_name);
+  auto cluster_it = cluster_name.empty() ? clusters.find(firstClusterName) : clusters.find(cluster_name);
 
   int i{1};
   for (const auto & slave_node : slave_nodes)
diff --git a/src/ConfigFile.hh b/src/ConfigFile.hh
index ad1c9b5c519348e24857ecde991a44c4d26f3b54..168e1f711892ab0e0ef7cd48d61af15adc328ec6 100644
--- a/src/ConfigFile.hh
+++ b/src/ConfigFile.hh
@@ -1,5 +1,5 @@
 /*
- * Copyright © 2010-2017 Dynare Team
+ * Copyright © 2010-2019 Dynare Team
  *
  * This file is part of Dynare.
  *
@@ -67,16 +67,11 @@ public:
             string operatingSystem_arg);
 
 protected:
-  const string computerName;
-  const string port;
-  int minCpuNbr;
-  int maxCpuNbr;
-  const string userName;
-  const string password;
-  const string remoteDrive;
-  const string remoteDirectory;
-  const string dynarePath;
-  const string matlabOctavePath;
+  const string computerName, port;
+  int minCpuNbr, maxCpuNbr;
+  const string userName, password;
+  const string remoteDrive, remoteDirectory;
+  const string dynarePath, matlabOctavePath;
   const bool singleCompThread;
   const int numberOfThreadsPerJob;
   const string operatingSystem;
@@ -99,9 +94,7 @@ public:
   ConfigFile(bool parallel_arg, bool parallel_test_arg, bool parallel_slave_open_mode_arg, string cluster_name);
 
 private:
-  const bool parallel;
-  const bool parallel_test;
-  const bool parallel_slave_open_mode;
+  const bool parallel, parallel_test, parallel_slave_open_mode;
   const string cluster_name;
   string firstClusterName;
   //! Hooks
diff --git a/src/DataTree.cc b/src/DataTree.cc
index 5b50efbc370d68c58b12d0daa30a47962266a5cc..869416cbcf556b650b07608329895fb73a73bccb 100644
--- a/src/DataTree.cc
+++ b/src/DataTree.cc
@@ -77,10 +77,10 @@ DataTree::DataTree(const DataTree &d) :
 DataTree &
 DataTree::operator=(const DataTree &d)
 {
-  assert (&symbol_table == &d.symbol_table);
-  assert (&num_constants == &d.num_constants);
-  assert (&external_functions_table == &d.external_functions_table);
-  assert (is_dynamic == d.is_dynamic);
+  assert(&symbol_table == &d.symbol_table);
+  assert(&num_constants == &d.num_constants);
+  assert(&external_functions_table == &d.external_functions_table);
+  assert(is_dynamic == d.is_dynamic);
 
   num_const_node_map.clear();
   variable_node_map.clear();
@@ -116,8 +116,8 @@ DataTree::AddNonNegativeConstant(const string &value)
 {
   int id = num_constants.AddNonNegativeConstant(value);
 
-  auto it = num_const_node_map.find(id);
-  if (it != num_const_node_map.end())
+  if (auto it = num_const_node_map.find(id);
+      it != num_const_node_map.end())
     return it->second;
 
   auto sp = make_unique<NumConstNode>(*this, node_list.size(), id);
@@ -136,8 +136,8 @@ DataTree::AddVariable(int symb_id, int lag)
       exit(EXIT_FAILURE);
     }
 
-  auto it = variable_node_map.find({ symb_id, lag });
-  if (it != variable_node_map.end())
+  if (auto it = variable_node_map.find({ symb_id, lag });
+      it != variable_node_map.end())
     return it->second;
 
   auto sp = make_unique<VariableNode>(*this, node_list.size(), symb_id, lag);
@@ -171,41 +171,37 @@ DataTree::ParamUsedWithLeadLagInternal() const
 expr_t
 DataTree::AddPlus(expr_t iArg1, expr_t iArg2)
 {
-  if (iArg1 != Zero && iArg2 != Zero)
-    {
-      // Simplify x+(-y) in x-y
-      if (auto uarg2 = dynamic_cast<UnaryOpNode *>(iArg2);
-          uarg2 && uarg2->op_code == UnaryOpcode::uminus)
-        return AddMinus(iArg1, uarg2->arg);
-
-      // Simplify (-x)+y in y-x
-      if (auto uarg1 = dynamic_cast<UnaryOpNode *>(iArg1);
-          uarg1 && uarg1->op_code == UnaryOpcode::uminus)
-        return AddMinus(iArg2, uarg1->arg);
-
-      // Simplify (x-y)+y in x
-      if (auto barg1 = dynamic_cast<BinaryOpNode *>(iArg1);
-          barg1 && barg1->op_code == BinaryOpcode::minus && barg1->arg2 == iArg2)
-        return barg1->arg1;
+  if (iArg2 == Zero)
+    return iArg1;
 
-      // Simplify y+(x-y) in x
-      if (auto barg2 = dynamic_cast<BinaryOpNode *>(iArg2);
-          barg2 && barg2->op_code == BinaryOpcode::minus && barg2->arg2 == iArg1)
-        return barg2->arg1;
+  if (iArg1 == Zero)
+    return iArg2;
 
-      // To treat commutativity of "+"
-      // Nodes iArg1 and iArg2 are sorted by index
-      if (iArg1->idx > iArg2->idx)
-        swap(iArg1, iArg2);
+  // Simplify x+(-y) in x-y
+  if (auto uarg2 = dynamic_cast<UnaryOpNode *>(iArg2);
+      uarg2 && uarg2->op_code == UnaryOpcode::uminus)
+    return AddMinus(iArg1, uarg2->arg);
 
-      return AddBinaryOp(iArg1, BinaryOpcode::plus, iArg2);
-    }
-  else if (iArg1 != Zero)
-    return iArg1;
-  else if (iArg2 != Zero)
-    return iArg2;
-  else
-    return Zero;
+  // Simplify (-x)+y in y-x
+  if (auto uarg1 = dynamic_cast<UnaryOpNode *>(iArg1);
+      uarg1 && uarg1->op_code == UnaryOpcode::uminus)
+    return AddMinus(iArg2, uarg1->arg);
+
+  // Simplify (x-y)+y in x
+  if (auto barg1 = dynamic_cast<BinaryOpNode *>(iArg1);
+      barg1 && barg1->op_code == BinaryOpcode::minus && barg1->arg2 == iArg2)
+    return barg1->arg1;
+
+  // Simplify y+(x-y) in x
+  if (auto barg2 = dynamic_cast<BinaryOpNode *>(iArg2);
+      barg2 && barg2->op_code == BinaryOpcode::minus && barg2->arg2 == iArg1)
+    return barg2->arg1;
+
+  // To treat commutativity of "+"
+  // Nodes iArg1 and iArg2 are sorted by index
+  if (iArg1->idx > iArg2->idx)
+    swap(iArg1, iArg2);
+  return AddBinaryOp(iArg1, BinaryOpcode::plus, iArg2);
 }
 
 expr_t
@@ -241,52 +237,50 @@ DataTree::AddMinus(expr_t iArg1, expr_t iArg2)
 expr_t
 DataTree::AddUMinus(expr_t iArg1)
 {
-  if (iArg1 != Zero)
-    {
-      // Simplify -(-x) in x
-      if (auto uarg = dynamic_cast<UnaryOpNode *>(iArg1);
-          uarg && uarg->op_code == UnaryOpcode::uminus)
-        return uarg->arg;
-
-      return AddUnaryOp(UnaryOpcode::uminus, iArg1);
-    }
-  else
+  if (iArg1 == Zero)
     return Zero;
+
+  // Simplify -(-x) in x
+  if (auto uarg = dynamic_cast<UnaryOpNode *>(iArg1);
+      uarg && uarg->op_code == UnaryOpcode::uminus)
+    return uarg->arg;
+
+  return AddUnaryOp(UnaryOpcode::uminus, iArg1);
 }
 
 expr_t
 DataTree::AddTimes(expr_t iArg1, expr_t iArg2)
 {
+  if (iArg1 == Zero || iArg2 == Zero)
+    return Zero;
+
+  if (iArg1 == One)
+    return iArg2;
+
+  if (iArg2 == One)
+    return iArg1;
+
   if (iArg1 == MinusOne)
     return AddUMinus(iArg2);
-  else if (iArg2 == MinusOne)
+
+  if (iArg2 == MinusOne)
     return AddUMinus(iArg1);
-  else if (iArg1 != Zero && iArg1 != One && iArg2 != Zero && iArg2 != One)
-    {
-      // Simplify (x/y)*y in x
-      if (auto barg1 = dynamic_cast<BinaryOpNode *>(iArg1);
-          barg1 && barg1->op_code == BinaryOpcode::divide && barg1->arg2 == iArg2)
-        return barg1->arg1;
 
-      // Simplify y*(x/y) in x
-      if (auto barg2 = dynamic_cast<BinaryOpNode *>(iArg2);
-          barg2 && barg2->op_code == BinaryOpcode::divide && barg2->arg2 == iArg1)
-        return barg2->arg1;
+  // Simplify (x/y)*y in x
+  if (auto barg1 = dynamic_cast<BinaryOpNode *>(iArg1);
+      barg1 && barg1->op_code == BinaryOpcode::divide && barg1->arg2 == iArg2)
+    return barg1->arg1;
 
-      // To treat commutativity of "*"
-      // Nodes iArg1 and iArg2 are sorted by index
-      if (iArg1->idx > iArg2->idx)
-        swap(iArg1, iArg2);
-      return AddBinaryOp(iArg1, BinaryOpcode::times, iArg2);
-    }
-  else if (iArg1 != Zero && iArg1 != One && iArg2 == One)
-    return iArg1;
-  else if (iArg2 != Zero && iArg2 != One && iArg1 == One)
-    return iArg2;
-  else if (iArg2 == One && iArg1 == One)
-    return One;
-  else
-    return Zero;
+  // Simplify y*(x/y) in x
+  if (auto barg2 = dynamic_cast<BinaryOpNode *>(iArg2);
+      barg2 && barg2->op_code == BinaryOpcode::divide && barg2->arg2 == iArg1)
+    return barg2->arg1;
+
+  // To treat commutativity of "*"
+  // Nodes iArg1 and iArg2 are sorted by index
+  if (iArg1->idx > iArg2->idx)
+    swap(iArg1, iArg2);
+  return AddBinaryOp(iArg1, BinaryOpcode::times, iArg2);
 }
 
 expr_t
@@ -365,16 +359,20 @@ DataTree::AddDifferent(expr_t iArg1, expr_t iArg2)
 expr_t
 DataTree::AddPower(expr_t iArg1, expr_t iArg2)
 {
-  if (iArg1 != Zero && iArg2 != Zero && iArg1 != One && iArg2 != One)
-    return AddBinaryOp(iArg1, BinaryOpcode::power, iArg2);
-  else if (iArg1 == One)
-    return One;
-  else if (iArg2 == One)
-    return iArg1;
-  else if (iArg2 == Zero)
+  // This one comes first, because 0⁰=1
+  if (iArg2 == Zero)
     return One;
-  else
+
+  if (iArg1 == Zero)
     return Zero;
+
+  if (iArg1 == One)
+    return One;
+
+  if (iArg2 == One)
+    return iArg1;
+
+  return AddBinaryOp(iArg1, BinaryOpcode::power, iArg2);
 }
 
 expr_t
@@ -402,10 +400,10 @@ DataTree::AddAdl(expr_t iArg1, const string &name, const vector<int> &lags)
 expr_t
 DataTree::AddExp(expr_t iArg1)
 {
-  if (iArg1 != Zero)
-    return AddUnaryOp(UnaryOpcode::exp, iArg1);
-  else
+  if (iArg1 == Zero)
     return One;
+
+  return AddUnaryOp(UnaryOpcode::exp, iArg1);
 }
 
 expr_t
@@ -420,9 +418,9 @@ DataTree::AddLog(expr_t iArg1)
       exit(EXIT_FAILURE);
     }
 
-  // Try to simplify log(1/x) into -log(x)
-  auto barg1 = dynamic_cast<BinaryOpNode *>(iArg1);
-  if (barg1 && barg1->op_code == BinaryOpcode::divide && barg1->arg1 == One)
+  // Simplify log(1/x) in −log(x)
+  if (auto barg1 = dynamic_cast<BinaryOpNode *>(iArg1);
+      barg1 && barg1->op_code == BinaryOpcode::divide && barg1->arg1 == One)
     return AddUMinus(AddLog(barg1->arg2));
 
   return AddUnaryOp(UnaryOpcode::log, iArg1);
@@ -440,9 +438,9 @@ DataTree::AddLog10(expr_t iArg1)
       exit(EXIT_FAILURE);
     }
 
-  // Try to simplify log10(1/x) into -log10(x)
-  auto barg1 = dynamic_cast<BinaryOpNode *>(iArg1);
-  if (barg1 && barg1->op_code == BinaryOpcode::divide && barg1->arg1 == One)
+  // Simplify log₁₀(1/x) in −log₁₀(x)
+  if (auto barg1 = dynamic_cast<BinaryOpNode *>(iArg1);
+      barg1 && barg1->op_code == BinaryOpcode::divide && barg1->arg1 == One)
     return AddUMinus(AddLog10(barg1->arg2));
 
   return AddUnaryOp(UnaryOpcode::log10, iArg1);
@@ -451,118 +449,121 @@ DataTree::AddLog10(expr_t iArg1)
 expr_t
 DataTree::AddCos(expr_t iArg1)
 {
-  if (iArg1 != Zero)
-    return AddUnaryOp(UnaryOpcode::cos, iArg1);
-  else
+  if (iArg1 == Zero)
     return One;
+
+  return AddUnaryOp(UnaryOpcode::cos, iArg1);
 }
 
 expr_t
 DataTree::AddSin(expr_t iArg1)
 {
-  if (iArg1 != Zero)
-    return AddUnaryOp(UnaryOpcode::sin, iArg1);
-  else
+  if (iArg1 == Zero)
     return Zero;
+
+  return AddUnaryOp(UnaryOpcode::sin, iArg1);
 }
 
 expr_t
 DataTree::AddTan(expr_t iArg1)
 {
-  if (iArg1 != Zero)
-    return AddUnaryOp(UnaryOpcode::tan, iArg1);
-  else
+  if (iArg1 == Zero)
     return Zero;
+
+  return AddUnaryOp(UnaryOpcode::tan, iArg1);
 }
 
 expr_t
 DataTree::AddAcos(expr_t iArg1)
 {
-  if (iArg1 != One)
-    return AddUnaryOp(UnaryOpcode::acos, iArg1);
-  else
+  if (iArg1 == One)
     return Zero;
+
+  return AddUnaryOp(UnaryOpcode::acos, iArg1);
 }
 
 expr_t
 DataTree::AddAsin(expr_t iArg1)
 {
-  if (iArg1 != Zero)
-    return AddUnaryOp(UnaryOpcode::asin, iArg1);
-  else
+  if (iArg1 == Zero)
     return Zero;
+
+  return AddUnaryOp(UnaryOpcode::asin, iArg1);
 }
 
 expr_t
 DataTree::AddAtan(expr_t iArg1)
 {
-  if (iArg1 != Zero)
-    return AddUnaryOp(UnaryOpcode::atan, iArg1);
-  else
+  if (iArg1 == Zero)
     return Zero;
+
+  return AddUnaryOp(UnaryOpcode::atan, iArg1);
 }
 
 expr_t
 DataTree::AddCosh(expr_t iArg1)
 {
-  if (iArg1 != Zero)
-    return AddUnaryOp(UnaryOpcode::cosh, iArg1);
-  else
+  if (iArg1 == Zero)
     return One;
+
+  return AddUnaryOp(UnaryOpcode::cosh, iArg1);
 }
 
 expr_t
 DataTree::AddSinh(expr_t iArg1)
 {
-  if (iArg1 != Zero)
-    return AddUnaryOp(UnaryOpcode::sinh, iArg1);
-  else
+  if (iArg1 == Zero)
     return Zero;
+
+  return AddUnaryOp(UnaryOpcode::sinh, iArg1);
 }
 
 expr_t
 DataTree::AddTanh(expr_t iArg1)
 {
-  if (iArg1 != Zero)
-    return AddUnaryOp(UnaryOpcode::tanh, iArg1);
-  else
+  if (iArg1 == Zero)
     return Zero;
+
+  return AddUnaryOp(UnaryOpcode::tanh, iArg1);
 }
 
 expr_t
 DataTree::AddAcosh(expr_t iArg1)
 {
-  if (iArg1 != One)
-    return AddUnaryOp(UnaryOpcode::acosh, iArg1);
-  else
+  if (iArg1 == One)
     return Zero;
+
+  return AddUnaryOp(UnaryOpcode::acosh, iArg1);
 }
 
 expr_t
 DataTree::AddAsinh(expr_t iArg1)
 {
-  if (iArg1 != Zero)
-    return AddUnaryOp(UnaryOpcode::asinh, iArg1);
-  else
+  if (iArg1 == Zero)
     return Zero;
+
+  return AddUnaryOp(UnaryOpcode::asinh, iArg1);
 }
 
 expr_t
 DataTree::AddAtanh(expr_t iArg1)
 {
-  if (iArg1 != Zero)
-    return AddUnaryOp(UnaryOpcode::atanh, iArg1);
-  else
+  if (iArg1 == Zero)
     return Zero;
+
+  return AddUnaryOp(UnaryOpcode::atanh, iArg1);
 }
 
 expr_t
 DataTree::AddSqrt(expr_t iArg1)
 {
-  if (iArg1 != Zero)
-    return AddUnaryOp(UnaryOpcode::sqrt, iArg1);
-  else
+  if (iArg1 == Zero)
     return Zero;
+
+  if (iArg1 == One)
+    return One;
+
+  return AddUnaryOp(UnaryOpcode::sqrt, iArg1);
 }
 
 expr_t
@@ -570,10 +571,11 @@ DataTree::AddCbrt(expr_t iArg1)
 {
   if (iArg1 == Zero)
     return Zero;
-  else if (iArg1 == One)
+
+  if (iArg1 == One)
     return One;
-  else
-    return AddUnaryOp(UnaryOpcode::cbrt, iArg1);
+
+  return AddUnaryOp(UnaryOpcode::cbrt, iArg1);
 }
 
 expr_t
@@ -581,10 +583,11 @@ DataTree::AddAbs(expr_t iArg1)
 {
   if (iArg1 == Zero)
     return Zero;
+
   if (iArg1 == One)
     return One;
-  else
-    return AddUnaryOp(UnaryOpcode::abs, iArg1);
+
+  return AddUnaryOp(UnaryOpcode::abs, iArg1);
 }
 
 expr_t
@@ -592,19 +595,20 @@ DataTree::AddSign(expr_t iArg1)
 {
   if (iArg1 == Zero)
     return Zero;
+
   if (iArg1 == One)
     return One;
-  else
-    return AddUnaryOp(UnaryOpcode::sign, iArg1);
+
+  return AddUnaryOp(UnaryOpcode::sign, iArg1);
 }
 
 expr_t
 DataTree::AddErf(expr_t iArg1)
 {
-  if (iArg1 != Zero)
-    return AddUnaryOp(UnaryOpcode::erf, iArg1);
-  else
+  if (iArg1 == Zero)
     return Zero;
+
+  return AddUnaryOp(UnaryOpcode::erf, iArg1);
 }
 
 expr_t
@@ -658,8 +662,8 @@ DataTree::AddExpectation(int iArg1, expr_t iArg2)
 expr_t
 DataTree::AddVarExpectation(const string &model_name)
 {
-  auto it = var_expectation_node_map.find(model_name);
-  if (it != var_expectation_node_map.end())
+  if (auto it = var_expectation_node_map.find(model_name);
+      it != var_expectation_node_map.end())
     return it->second;
 
   auto sp = make_unique<VarExpectationNode>(*this, node_list.size(), model_name);
@@ -672,8 +676,8 @@ DataTree::AddVarExpectation(const string &model_name)
 expr_t
 DataTree::AddPacExpectation(const string &model_name)
 {
-  auto it = pac_expectation_node_map.find(model_name);
-  if (it != pac_expectation_node_map.end())
+  if (auto it = pac_expectation_node_map.find(model_name);
+      it != pac_expectation_node_map.end())
     return it->second;
 
   auto sp = make_unique<PacExpectationNode>(*this, node_list.size(), model_name);
@@ -695,8 +699,8 @@ DataTree::AddLocalVariable(int symb_id, expr_t value) noexcept(false)
   assert(symbol_table.getType(symb_id) == SymbolType::modelLocalVariable);
 
   // Throw an exception if symbol already declared
-  auto it = local_variables_table.find(symb_id);
-  if (it != local_variables_table.end())
+  if (auto it = local_variables_table.find(symb_id);
+      it != local_variables_table.end())
     throw LocalVariableException(symbol_table.getName(symb_id));
 
   local_variables_table[symb_id] = value;
@@ -708,8 +712,8 @@ DataTree::AddExternalFunction(int symb_id, const vector<expr_t> &arguments)
 {
   assert(symbol_table.getType(symb_id) == SymbolType::externalFunction);
 
-  auto it = external_function_node_map.find({ arguments, symb_id });
-  if (it != external_function_node_map.end())
+  if (auto it = external_function_node_map.find({ arguments, symb_id });
+      it != external_function_node_map.end())
     return it->second;
 
   auto sp = make_unique<ExternalFunctionNode>(*this, node_list.size(), symb_id, arguments);
@@ -724,9 +728,8 @@ DataTree::AddFirstDerivExternalFunction(int top_level_symb_id, const vector<expr
 {
   assert(symbol_table.getType(top_level_symb_id) == SymbolType::externalFunction);
 
-  auto it
-    = first_deriv_external_function_node_map.find({ arguments, input_index, top_level_symb_id });
-  if (it != first_deriv_external_function_node_map.end())
+  if (auto it = first_deriv_external_function_node_map.find({ arguments, input_index, top_level_symb_id });
+      it != first_deriv_external_function_node_map.end())
     return it->second;
 
   auto sp = make_unique<FirstDerivExternalFunctionNode>(*this, node_list.size(), top_level_symb_id, arguments, input_index);
@@ -741,10 +744,9 @@ DataTree::AddSecondDerivExternalFunction(int top_level_symb_id, const vector<exp
 {
   assert(symbol_table.getType(top_level_symb_id) == SymbolType::externalFunction);
 
-  auto it
-    = second_deriv_external_function_node_map.find({ arguments, input_index1, input_index2,
-          top_level_symb_id });
-  if (it != second_deriv_external_function_node_map.end())
+  if (auto it = second_deriv_external_function_node_map.find({ arguments, input_index1, input_index2,
+                                                               top_level_symb_id });
+    it != second_deriv_external_function_node_map.end())
     return it->second;
 
   auto sp = make_unique<SecondDerivExternalFunctionNode>(*this, node_list.size(), top_level_symb_id, arguments, input_index1, input_index2);
diff --git a/src/DataTree.hh b/src/DataTree.hh
index 6fb6bb71ec02f1a94670714611c099030352de77..b5fcd6eb7919546518e4d449f54c323a1d261431 100644
--- a/src/DataTree.hh
+++ b/src/DataTree.hh
@@ -365,18 +365,18 @@ inline expr_t
 DataTree::AddUnaryOp(UnaryOpcode op_code, expr_t arg, int arg_exp_info_set, int param1_symb_id, int param2_symb_id, const string &adl_param_name, const vector<int> &adl_lags)
 {
   // If the node already exists in tree, share it
-  auto it = unary_op_node_map.find({ arg, op_code, arg_exp_info_set, param1_symb_id, param2_symb_id, adl_param_name, adl_lags });
-  if (it != unary_op_node_map.end())
+  if (auto it = unary_op_node_map.find({ arg, op_code, arg_exp_info_set, param1_symb_id, param2_symb_id, adl_param_name, adl_lags });
+      it != unary_op_node_map.end())
     return it->second;
 
   // Try to reduce to a constant
   // Case where arg is a constant and op_code == UnaryOpcode::uminus (i.e. we're adding a negative constant) is skipped
-  auto *carg = dynamic_cast<NumConstNode *>(arg);
-  if (op_code != UnaryOpcode::uminus || carg == nullptr)
+  if (auto carg = dynamic_cast<NumConstNode *>(arg);
+      op_code != UnaryOpcode::uminus || !carg)
     {
       try
         {
-          double argval = arg->eval(eval_context_t());
+          double argval = arg->eval({});
           double val = UnaryOpNode::eval_opcode(op_code, argval);
           return AddPossiblyNegativeConstant(val);
         }
@@ -395,15 +395,15 @@ DataTree::AddUnaryOp(UnaryOpcode op_code, expr_t arg, int arg_exp_info_set, int
 inline expr_t
 DataTree::AddBinaryOp(expr_t arg1, BinaryOpcode op_code, expr_t arg2, int powerDerivOrder)
 {
-  auto it = binary_op_node_map.find({ arg1, arg2, op_code, powerDerivOrder });
-  if (it != binary_op_node_map.end())
+  if (auto it = binary_op_node_map.find({ arg1, arg2, op_code, powerDerivOrder });
+      it != binary_op_node_map.end())
     return it->second;
 
   // Try to reduce to a constant
   try
     {
-      double argval1 = arg1->eval(eval_context_t());
-      double argval2 = arg2->eval(eval_context_t());
+      double argval1 = arg1->eval({});
+      double argval2 = arg2->eval({});
       double val = BinaryOpNode::eval_opcode(argval1, op_code, argval2, powerDerivOrder);
       return AddPossiblyNegativeConstant(val);
     }
@@ -421,16 +421,16 @@ DataTree::AddBinaryOp(expr_t arg1, BinaryOpcode op_code, expr_t arg2, int powerD
 inline expr_t
 DataTree::AddTrinaryOp(expr_t arg1, TrinaryOpcode op_code, expr_t arg2, expr_t arg3)
 {
-  auto it = trinary_op_node_map.find({ arg1, arg2, arg3, op_code });
-  if (it != trinary_op_node_map.end())
+  if (auto it = trinary_op_node_map.find({ arg1, arg2, arg3, op_code });
+      it != trinary_op_node_map.end())
     return it->second;
 
   // Try to reduce to a constant
   try
     {
-      double argval1 = arg1->eval(eval_context_t());
-      double argval2 = arg2->eval(eval_context_t());
-      double argval3 = arg3->eval(eval_context_t());
+      double argval1 = arg1->eval({});
+      double argval2 = arg2->eval({});
+      double argval3 = arg3->eval({});
       double val = TrinaryOpNode::eval_opcode(argval1, op_code, argval2, argval3);
       return AddPossiblyNegativeConstant(val);
     }
diff --git a/src/DynamicModel.cc b/src/DynamicModel.cc
index 4cb2ab3e98d02c69127b1a73ff8065cc56a81399..d6fd707543559dfcf81b8c0d40f99e3dab54ace9 100644
--- a/src/DynamicModel.cc
+++ b/src/DynamicModel.cc
@@ -246,7 +246,7 @@ DynamicModel::compileDerivative(ofstream &code_file, unsigned int &instruction_n
 {
   if (auto it = derivatives[1].find({ eq, getDerivID(symbol_table.getID(SymbolType::endogenous, symb_id), lag) });
       it != derivatives[1].end())
-    (it->second)->compile(code_file, instruction_number, false, temporary_terms, map_idx, true, false);
+    it->second->compile(code_file, instruction_number, false, temporary_terms, map_idx, true, false);
   else
     {
       FLDZ_ fldz;
@@ -258,7 +258,7 @@ void
 DynamicModel::compileChainRuleDerivative(ofstream &code_file, unsigned int &instruction_number, int eqr, int varr, int lag, const map_idx_t &map_idx) const
 {
   if (auto it = first_chain_rule_derivatives.find({ eqr, varr, lag }); it != first_chain_rule_derivatives.end())
-    (it->second)->compile(code_file, instruction_number, false, temporary_terms, map_idx, true, false);
+    it->second->compile(code_file, instruction_number, false, temporary_terms, map_idx, true, false);
   else
     {
       FLDZ_ fldz;
@@ -403,7 +403,6 @@ DynamicModel::writeModelEquationsOrdered_M(const string &basename) const
   int nze, nze_exo, nze_exo_det, nze_other_endo;
   vector<int> feedback_variables;
   ExprNodeOutputType local_output_type;
-  Ufoss.str("");
 
   local_output_type = ExprNodeOutputType::matlabDynamicModelSparse;
   if (global_temporary_terms)
@@ -1005,17 +1004,17 @@ DynamicModel::writeModelEquationsCode(const string &basename, const map_idx_t &m
 
   map<tuple<int, int, int>, expr_t> first_derivatives_reordered_endo;
   map<tuple<int, SymbolType, int, int>, expr_t> first_derivatives_reordered_exo;
-  for (const auto & first_derivative : derivatives[1])
+  for (const auto & [indices, d1] : derivatives[1])
     {
-      int deriv_id = first_derivative.first[1];
-      unsigned int eq = first_derivative.first[0];
+      int deriv_id = indices[1];
+      unsigned int eq = indices[0];
       int symb = getSymbIDByDerivID(deriv_id);
       unsigned int var = symbol_table.getTypeSpecificID(symb);
       int lag = getLagByDerivID(deriv_id);
       if (getTypeByDerivID(deriv_id) == SymbolType::endogenous)
-        first_derivatives_reordered_endo[{ lag, var, eq }] = first_derivative.second;
+        first_derivatives_reordered_endo[{ lag, var, eq }] = d1;
       else if (getTypeByDerivID(deriv_id) == SymbolType::exogenous || getTypeByDerivID(deriv_id) == SymbolType::exogenousDet)
-        first_derivatives_reordered_exo[{ lag, getTypeByDerivID(deriv_id), var, eq }] = first_derivative.second;
+        first_derivatives_reordered_exo[{ lag, getTypeByDerivID(deriv_id), var, eq }] = d1;
     }
   int prev_var = -1;
   int prev_lag = -999999999;
@@ -1093,13 +1092,12 @@ DynamicModel::writeModelEquationsCode(const string &basename, const map_idx_t &m
 
   vector<vector<tuple<int, int, int>>> my_derivatives(symbol_table.endo_nbr());;
   count_u = symbol_table.endo_nbr();
-  for (const auto & first_derivative : derivatives[1])
+  for (const auto & [indices, d1] : derivatives[1])
     {
-      int deriv_id = first_derivative.first[1];
+      int deriv_id = indices[1];
       if (getTypeByDerivID(deriv_id) == SymbolType::endogenous)
         {
-          expr_t d1 = first_derivative.second;
-          unsigned int eq = first_derivative.first[0];
+          unsigned int eq = indices[0];
           int symb = getSymbIDByDerivID(deriv_id);
           unsigned int var = symbol_table.getTypeSpecificID(symb);
           int lag = getLagByDerivID(deriv_id);
@@ -1121,7 +1119,7 @@ DynamicModel::writeModelEquationsCode(const string &basename, const map_idx_t &m
       fldr.write(code_file, instruction_number);
       if (my_derivatives[i].size())
         {
-          for (auto it = my_derivatives[i].begin(); it != my_derivatives[i].end(); it++)
+          for (auto it = my_derivatives[i].begin(); it != my_derivatives[i].end(); ++it)
             {
               FLDU_ fldu(get<2>(*it));
               fldu.write(code_file, instruction_number);
@@ -1211,7 +1209,7 @@ DynamicModel::writeModelEquationsCode(const string &basename, const map_idx_t &m
 }
 
 void
-DynamicModel::writeModelEquationsCode_Block(const string &basename, const map_idx_t &map_idx, const bool linear_decomposition) const
+DynamicModel::writeModelEquationsCode_Block(const string &basename, const map_idx_t &map_idx, bool linear_decomposition) const
 {
   struct Uff_l
   {
@@ -1463,8 +1461,8 @@ DynamicModel::writeModelEquationsCode_Block(const string &basename, const map_id
       fjmp_if_eval.write(code_file, instruction_number);
       int prev_instruction_number = instruction_number;
       // The Jacobian if we have to solve the block determinsitic block
-      if    (simulation_type != EVALUATE_BACKWARD
-             && simulation_type != EVALUATE_FORWARD)
+      if (simulation_type != EVALUATE_BACKWARD
+          && simulation_type != EVALUATE_FORWARD)
         {
           switch (simulation_type)
             {
@@ -1617,7 +1615,7 @@ DynamicModel::writeModelEquationsCode_Block(const string &basename, const map_id
           FNUMEXPR_ fnumexpr(FirstExoDerivative, eqr, varr, lag);
           fnumexpr.write(code_file, instruction_number);
           id->compile(code_file, instruction_number, false, temporary_terms, map_idx, true, false);
-          FSTPG3_ fstpg3(eq, var, lag, /*var*/ count_col_exo-1);
+          FSTPG3_ fstpg3(eq, var, lag, count_col_exo-1);
           fstpg3.write(code_file, instruction_number);
         }
       prev_var = -1;
@@ -1694,7 +1692,7 @@ DynamicModel::writeDynamicJuliaFile(const string &basename) const
 }
 
 void
-DynamicModel::writeDynamicCFile(const string &basename, const int order) const
+DynamicModel::writeDynamicCFile(const string &basename, int order) const
 {
   filesystem::create_directories(basename + "/model/src");
   string filename = basename + "/model/src/dynamic.c";
@@ -1848,7 +1846,7 @@ DynamicModel::writeDynamicCFile(const string &basename, const int order) const
 }
 
 string
-DynamicModel::reform(const string name1) const
+DynamicModel::reform(const string &name1) const
 {
   string name = name1;
   int pos = name.find(R"(\)", 0);
@@ -1862,16 +1860,16 @@ DynamicModel::reform(const string name1) const
       pos++;
       pos = name.find(R"(\)", pos);
     }
-  return (name);
+  return name;
 }
 
 void
 DynamicModel::printNonZeroHessianEquations(ostream &output) const
 {
-  if (nonzero_hessian_eqs.size() !=  1)
+  if (nonzero_hessian_eqs.size() != 1)
     output << "[";
   for (auto it = nonzero_hessian_eqs.begin();
-       it != nonzero_hessian_eqs.end(); it++)
+       it != nonzero_hessian_eqs.end(); ++it)
     {
       if (it != nonzero_hessian_eqs.begin())
         output << " ";
@@ -1882,8 +1880,8 @@ DynamicModel::printNonZeroHessianEquations(ostream &output) const
 }
 
 void
-DynamicModel::Write_Inf_To_Bin_File_Block(const string &basename, const int &num,
-                                          int &u_count_int, bool &file_open, bool is_two_boundaries, const bool linear_decomposition) const
+DynamicModel::Write_Inf_To_Bin_File_Block(const string &basename, int num,
+                                          int &u_count_int, bool &file_open, bool is_two_boundaries, bool linear_decomposition) const
 {
   int j;
   std::ofstream SaveCode;
@@ -1948,7 +1946,6 @@ DynamicModel::writeSparseDynamicMFile(const string &basename) const
   string sp;
   ofstream mDynamicModelFile;
   ostringstream tmp, tmp1, tmp_eq;
-  bool OK;
   string filename = packageDir(basename) + "/dynamic.m";
   mDynamicModelFile.open(filename, ios::out | ios::binary);
   if (!mDynamicModelFile.is_open())
@@ -1969,7 +1966,7 @@ DynamicModel::writeSparseDynamicMFile(const string &basename) const
   mDynamicModelFile << "function [varargout] = dynamic(options_, M_, oo_, varargin)" << endl
                     << "  g2=[];g3=[];" << endl;
   //Temporary variables declaration
-  OK = true;
+  bool OK = true;
   ostringstream tmp_output;
   for (auto temporary_term : temporary_terms)
     {
@@ -2015,9 +2012,9 @@ DynamicModel::writeSparseDynamicMFile(const string &basename) const
   unsigned int block = 0;
   for (int count_call = 1; block < nb_blocks; block++, count_call++)
     {
-      unsigned int block_size = getBlockSize(block);
-      unsigned int block_mfs = getBlockMfs(block);
-      unsigned int block_recursive = block_size - block_mfs;
+      unsigned int block_size = getBlockSize(block),
+        block_mfs = getBlockMfs(block),
+        block_recursive = block_size - block_mfs;
       BlockSimulationType simulation_type = getBlockSimulationType(block);
 
       if (simulation_type == EVALUATE_FORWARD || simulation_type == EVALUATE_BACKWARD)
@@ -2110,7 +2107,7 @@ DynamicModel::writeSparseDynamicMFile(const string &basename) const
       unsigned int block_recursive = block_size - block_mfs;
       BlockSimulationType simulation_type = getBlockSimulationType(block);
 
-      if ((simulation_type == EVALUATE_FORWARD) && (block_size))
+      if (simulation_type == EVALUATE_FORWARD && block_size)
         {
           if (open_par)
             mDynamicModelFile << "  end" << endl;
@@ -2136,7 +2133,7 @@ DynamicModel::writeSparseDynamicMFile(const string &basename) const
                             << "    return;" << endl
                             << "  end;" << endl;
         }
-      else if ((simulation_type == EVALUATE_BACKWARD) && (block_size))
+      else if (simulation_type == EVALUATE_BACKWARD && block_size)
         {
           if (open_par)
             mDynamicModelFile << "  end" << endl;
@@ -2162,7 +2159,7 @@ DynamicModel::writeSparseDynamicMFile(const string &basename) const
                             << "    return;" << endl
                             << "  end;" << endl;
         }
-      else if ((simulation_type == SOLVE_FORWARD_COMPLETE || simulation_type == SOLVE_FORWARD_SIMPLE) && (block_size))
+      else if ((simulation_type == SOLVE_FORWARD_COMPLETE || simulation_type == SOLVE_FORWARD_SIMPLE) && block_size)
         {
           if (open_par)
             mDynamicModelFile << "  end" << endl;
@@ -2192,7 +2189,7 @@ DynamicModel::writeSparseDynamicMFile(const string &basename) const
                             << "    return;" << endl
                             << "  end;" << endl;
         }
-      else if ((simulation_type == SOLVE_BACKWARD_COMPLETE || simulation_type == SOLVE_BACKWARD_SIMPLE) && (block_size))
+      else if ((simulation_type == SOLVE_BACKWARD_COMPLETE || simulation_type == SOLVE_BACKWARD_SIMPLE) && block_size)
         {
           if (open_par)
             mDynamicModelFile << "  end" << endl;
@@ -2223,7 +2220,7 @@ DynamicModel::writeSparseDynamicMFile(const string &basename) const
                             << "    return;" << endl
                             << "  end;" << endl;
         }
-      else if ((simulation_type == SOLVE_TWO_BOUNDARIES_COMPLETE || simulation_type == SOLVE_TWO_BOUNDARIES_SIMPLE) && (block_size))
+      else if ((simulation_type == SOLVE_TWO_BOUNDARIES_COMPLETE || simulation_type == SOLVE_TWO_BOUNDARIES_SIMPLE) && block_size)
         {
           if (open_par)
             mDynamicModelFile << "  end" << endl;
@@ -2513,10 +2510,8 @@ DynamicModel::writeDynamicModel(const string &basename, ostream &DynamicOutput,
         ostringstream col0_output, col1_output, col2_output;
 
         int k = 0; // Current line index in the 3-column matrix
-        for (const auto &dit : derivatives[i])
+        for (const auto &[vidx, d] : derivatives[i])
           {
-            const vector<int> &vidx = dit.first;
-            expr_t d = dit.second;
             int eq = vidx[0];
 
             int col_idx = 0;
@@ -2875,18 +2870,18 @@ void
 DynamicModel::writeDynamicJacobianNonZeroElts(const string &basename) const
 {
   vector<pair<int, int>> nzij_pred, nzij_current, nzij_fwrd; // pairs (tsid, equation)
-  for (const auto &it : derivatives[1])
+  for (const auto &[indices, d1] : derivatives[1])
     {
-      if (symbol_table.getType(getSymbIDByDerivID(it.first[1])) != SymbolType::endogenous)
+      if (symbol_table.getType(getSymbIDByDerivID(indices[1])) != SymbolType::endogenous)
         continue;
-      int tsid = symbol_table.getTypeSpecificID(getSymbIDByDerivID(it.first[1]));
-      int lag = getLagByDerivID(it.first[1]);
+      int tsid = symbol_table.getTypeSpecificID(getSymbIDByDerivID(indices[1]));
+      int lag = getLagByDerivID(indices[1]);
       if (lag == -1)
-        nzij_pred.emplace_back(tsid, it.first[0]);
+        nzij_pred.emplace_back(tsid, indices[0]);
       else if (lag == 0)
-        nzij_current.emplace_back(tsid, it.first[0]);
+        nzij_current.emplace_back(tsid, indices[0]);
       else
-        nzij_fwrd.emplace_back(tsid, it.first[0]);
+        nzij_fwrd.emplace_back(tsid, indices[0]);
     }
   sort(nzij_pred.begin(), nzij_pred.end());
   sort(nzij_current.begin(), nzij_current.end());
@@ -2966,7 +2961,7 @@ DynamicModel::parseIncludeExcludeEquations(const string &inc_exc_eq_tags, set<pa
     tags = tags.substr(1, tags.length() - 2);
   removeLeadingTrailingWhitespace(tags);
 
-  regex q ("^\\w+\\s*=");
+  regex q (R"(^\w+\s*=)");
   smatch matches;
   string tagname = "name";
   if (regex_search(tags, matches, q))
@@ -2984,8 +2979,8 @@ DynamicModel::parseIncludeExcludeEquations(const string &inc_exc_eq_tags, set<pa
     }
 
   string quote_regex = "'[^']+'";
-  string non_quote_regex = "[^,\\s]+";
-  regex r ("(\\s*" + quote_regex + "|" + non_quote_regex + "\\s*)(,\\s*(" + quote_regex + "|" + non_quote_regex + ")\\s*)*");
+  string non_quote_regex = R"([^,\s]+)";
+  regex r (R"((\s*)" + quote_regex + "|" + non_quote_regex + R"(\s*)(,\s*()" + quote_regex + "|" + non_quote_regex + R"()\s*)*)");
   if (!regex_match (tags, r))
     {
       cerr << "Error: " << (exclude_eqs ? "exclude_eqs" : "include_eqs")
@@ -2995,7 +2990,7 @@ DynamicModel::parseIncludeExcludeEquations(const string &inc_exc_eq_tags, set<pa
 
   regex s (quote_regex + "|" + non_quote_regex);
   for (auto it = sregex_iterator(tags.begin(), tags.end(), s);
-      it != sregex_iterator(); it++)
+      it != sregex_iterator(); ++it)
     {
       auto str = it->str();
       if (str[0] == '\'' && str[str.size()-1] == '\'')
@@ -3097,8 +3092,7 @@ DynamicModel::writeOutput(ostream &output, const string &basename, bool block_de
      model at a given period.
   */
 
-  string modstruct;
-  string outstruct;
+  string modstruct, outstruct;
   if (julia)
     {
       modstruct = "model_.";
@@ -3122,16 +3116,16 @@ DynamicModel::writeOutput(ostream &output, const string &basename, bool block_de
          << modstruct << "lead_lag_incidence = [";
   // Loop on endogenous variables
   int nstatic = 0,
-    nfwrd   = 0,
-    npred   = 0,
-    nboth   = 0;
+    nfwrd = 0,
+    npred = 0,
+    nboth = 0;
   for (int endoID = 0; endoID < symbol_table.endo_nbr(); endoID++)
     {
       output << endl;
       int sstatic = 1,
-        sfwrd   = 0,
-        spred   = 0,
-        sboth   = 0;
+        sfwrd = 0,
+        spred = 0,
+        sboth = 0;
       // Loop on periods
       for (int lag = -max_endo_lag; lag <= max_endo_lead; lag++)
         {
@@ -3224,8 +3218,8 @@ DynamicModel::writeOutput(ostream &output, const string &basename, bool block_de
 
   // Say if model contains an external function call
   bool has_external_function = false;
-  for (size_t eq = 0; eq < equations.size(); eq++)
-    if (equations[eq]->containsExternalFunction())
+  for (auto equation : equations)
+    if (equation->containsExternalFunction())
       {
         has_external_function = true;
         break;
@@ -3305,70 +3299,57 @@ DynamicModel::writeOutput(ostream &output, const string &basename, bool block_de
                  << "block_structure.block(" << block+1 << ").exo_nbr = " << getBlockExoSize(block) << ";" << endl
                  << "block_structure.block(" << block+1 << ").exogenous = [";
           int i = 0;
-          for (int exogenou : exogenous)
-            if (exogenou >= 0)
+          for (int exo : exogenous)
+            if (exo >= 0)
               {
-                output << " " << exogenou+1;
+                output << " " << exo+1;
                 i++;
               }
           output << "];" << endl
                  << "block_structure.block(" << block+1 << ").exogenous_det = [";
           i = 0;
-          for (int it_exogenous_det : exogenous_det)
-            if (it_exogenous_det >= 0)
+          for (int exo_det : exogenous_det)
+            if (exo_det >= 0)
               {
-                output << " " << it_exogenous_det+1;
+                output << " " << exo_det+1;
                 i++;
               }
           output << "];" << endl
                  << "block_structure.block(" << block+1 << ").exo_det_nbr = " << i << ";" << endl
                  << "block_structure.block(" << block+1 << ").other_endogenous = [";
           i = 0;
-          for (int other_endogenou : other_endogenous)
-            if (other_endogenou >= 0)
+          for (int other_endo : other_endogenous)
+            if (other_endo >= 0)
               {
-                output << " " << other_endogenou+1;
+                output << " " << other_endo+1;
                 i++;
               }
           output << "];" << endl
                  << "block_structure.block(" << block+1 << ").other_endogenous_block = [";
           i = 0;
-          for (int other_endogenou : other_endogenous)
-            if (other_endogenou >= 0)
+          for (int other_endo : other_endogenous)
+            if (other_endo >= 0)
               {
                 bool OK = true;
                 unsigned int j;
                 for (j = 0; j < block && OK; j++)
                   for (unsigned int k = 0; k < getBlockSize(j) && OK; k++)
-                    {
-                      //printf("*it_other_endogenous=%d, getBlockVariableID(%d, %d)=%d\n",*it_other_endogenous, j, k, getBlockVariableID(j, k));
-                      OK = other_endogenou != getBlockVariableID(j, k);
-                    }
+                    OK = other_endo != getBlockVariableID(j, k);
                 if (!OK)
                   output << " " << j;
                 i++;
               }
           output << "];" << endl;
 
-          //vector<int> inter_state_var;
           output << "block_structure.block(" << block+1 << ").tm1 = zeros(" << i << ", " << state_var.size() << ");" << endl;
           int count_other_endogenous = 1;
-          for (int other_endogenou : other_endogenous)
+          for (int other_endo : other_endogenous)
             {
               for (auto it = state_var.begin(); it != state_var.end(); ++it)
-                {
-                  //cout << "block = " << block+1 << " state_var = " << *it << " it_other_endogenous=" << *it_other_endogenous + 1 << "\n";
-                  if (*it == other_endogenou + 1)
-                    {
-                      output << "block_structure.block(" << block+1 << ").tm1("
-                             << count_other_endogenous << ", "
-                             << it - state_var.begin()+1 << ") = 1;" << endl;
-                      /*output << "block_structure.block(" << block+1 << ").tm1("
-                        << it - state_var.begin()+1 << ", "
-                        << count_other_endogenous << ") = 1;\n";*/
-                      //cout << "=>\n";
-                    }
-                }
+                if (*it == other_endo + 1)
+                  output << "block_structure.block(" << block+1 << ").tm1("
+                         << count_other_endogenous << ", "
+                         << it - state_var.begin()+1 << ") = 1;" << endl;
               count_other_endogenous++;
             }
 
@@ -3446,14 +3427,14 @@ DynamicModel::writeOutput(ostream &output, const string &basename, bool block_de
           for (int lag = -1; lag <= 1; lag++)
             {
               tmp_s.str("");
-              for (int other_endogenou : other_endogenous)
+              for (int other_endo : other_endogenous)
                 {
                   bool done = false;
                   for (int i = 0; i < block_size; i++)
                     {
                       unsigned int eq = getBlockEquationID(block, i);
-                      auto it = derivative_other_endo[block].find({ lag, eq, other_endogenou });
-                      if (it != derivative_other_endo[block].end())
+                      if (derivative_other_endo[block].find({ lag, eq, other_endo })
+                          != derivative_other_endo[block].end())
                         {
                           count_lead_lag_incidence++;
                           tmp_s << " " << count_lead_lag_incidence;
@@ -3491,12 +3472,12 @@ DynamicModel::writeOutput(ostream &output, const string &basename, bool block_de
         state_equ.push_back(equation_reordered[variable_inv_reordered[it - 1]]+1);
 
       map<tuple<int, int, int>,  int> lag_row_incidence;
-      for (const auto & first_derivative : derivatives[1])
+      for (const auto & [indices, d1] : derivatives[1])
         {
-          int deriv_id = first_derivative.first[1];
+          int deriv_id = indices[1];
           if (getTypeByDerivID(deriv_id) == SymbolType::endogenous)
             {
-              int eq = first_derivative.first[0];
+              int eq = indices[0];
               int symb = getSymbIDByDerivID(deriv_id);
               int var = symbol_table.getTypeSpecificID(symb);
               int lag = getLagByDerivID(deriv_id);
@@ -3532,7 +3513,6 @@ DynamicModel::writeOutput(ostream &output, const string &basename, bool block_de
           int n = n_obs + n_state;
           output << modstruct << "nobs_non_statevar = " << n_obs << ";" << endl;
           int nb_diag = 0;
-          //map<pair<int,int>, int>::const_iterator  row_state_var_incidence_it = row_state_var_incidence.begin();
 
           vector<int> i_nz_state_var(n);
           for (int i = 0; i < n_obs; i++)
@@ -3547,36 +3527,19 @@ DynamicModel::writeOutput(ostream &output, const string &basename, bool block_de
               for (int i = 0; i < block_size; i++)
                 {
                   int var = getBlockVariableID(block, i);
-                  auto it_state_var = find(state_var.begin(), state_var.end(), var+1);
-                  if (it_state_var != state_var.end())
+                  if (find(state_var.begin(), state_var.end(), var+1) != state_var.end())
                     nze++;
                 }
               if (block == 0)
                 {
                   set<pair<int, int>> row_state_var_incidence;
                   for (const auto &it : blocks_derivatives[block])
-                    {
-                      auto it_state_var = find(state_var.begin(), state_var.end(), getBlockVariableID(block, get<1>(it))+1);
-                      if (it_state_var != state_var.end())
-                        {
-                          auto it_state_equ = find(state_equ.begin(), state_equ.end(), getBlockEquationID(block, get<0>(it))+1);
-                          if (it_state_equ != state_equ.end())
-                            row_state_var_incidence.emplace(it_state_equ - state_equ.begin(), it_state_var - state_var.begin());
-                        }
-
-                    }
-                  /*tmp_block_endo_derivative[make_pair(it->second.first, make_pair(it->first.second, it->first.first))] = it->second.second;
-                    if (block == 0)
-                    {
-
-                    vector<int>::const_iterator it_state_equ = find(state_equ.begin(), state_equ.end(), getBlockEquationID(block, i)+1);
-                    if (it_state_equ != state_equ.end())
-                    {
-                    cout << "row_state_var_incidence[make_pair([" << *it_state_equ << "] " << it_state_equ - state_equ.begin() << ", [" << *it_state_var << "] " << it_state_var - state_var.begin() << ")] =  1;\n";
-                    row_state_var_incidence.insert(make_pair(it_state_equ - state_equ.begin(), it_state_var - state_var.begin()));
-                    }
-                    }*/
-                  auto  row_state_var_incidence_it = row_state_var_incidence.begin();
+                    if (auto it_state_var = find(state_var.begin(), state_var.end(), getBlockVariableID(block, get<1>(it))+1);
+                        it_state_var != state_var.end())
+                      if (auto it_state_equ = find(state_equ.begin(), state_equ.end(), getBlockEquationID(block, get<0>(it))+1);
+                          it_state_equ != state_equ.end())
+                        row_state_var_incidence.emplace(it_state_equ - state_equ.begin(), it_state_var - state_var.begin());
+                  auto row_state_var_incidence_it = row_state_var_incidence.begin();
                   bool diag = true;
                   int nb_diag_r = 0;
                   while (row_state_var_incidence_it != row_state_var_incidence.end() && diag)
@@ -3591,10 +3554,10 @@ DynamicModel::writeOutput(ostream &output, const string &basename, bool block_de
                         }
 
                     }
-                  set<pair<int, int>>  col_state_var_incidence;
-                  for (const auto & row_state_var_incidence_it : row_state_var_incidence)
-                    col_state_var_incidence.emplace(row_state_var_incidence_it.second, row_state_var_incidence_it.first);
-                  auto  col_state_var_incidence_it = col_state_var_incidence.begin();
+                  set<pair<int, int>> col_state_var_incidence;
+                  for (const auto & it : row_state_var_incidence)
+                    col_state_var_incidence.emplace(it.second, it.first);
+                  auto col_state_var_incidence_it = col_state_var_incidence.begin();
                   diag = true;
                   int nb_diag_c = 0;
                   while (col_state_var_incidence_it != col_state_var_incidence.end() && diag)
@@ -3626,16 +3589,13 @@ DynamicModel::writeOutput(ostream &output, const string &basename, bool block_de
           using index_KF = pair<int, pair<int, int >>;
           vector<index_KF> v_index_KF;
           for (int i = 0; i < n; i++)
-            //int i = 0;
             for (int j = n_obs; j < n; j++)
               {
                 int j1 = j - n_obs;
                 int j1_n_state = j1 * n_state - n_obs;
                 if ((i < n_obs) || (i >= nb_diag + n_obs) || (j1 >= nb_diag))
                   for (int k = n_obs; k < i_nz_state_var[i]; k++)
-                    {
-                      v_index_KF.emplace_back(i + j1 * n, pair(i + k * n, k + j1_n_state));
-                    }
+                    v_index_KF.emplace_back(i + j1 * n, pair(i + k * n, k + j1_n_state));
               }
           int size_v_index_KF = v_index_KF.size();
 
@@ -3646,7 +3606,6 @@ DynamicModel::writeOutput(ostream &output, const string &basename, bool block_de
           vector<index_KF> v_index_KF_2;
           int n_n_obs = n * n_obs;
           for (int i = 0; i < n; i++)
-            //i = 0;
             for (int j = i; j < n; j++)
               {
                 if ((i < n_obs) || (i >= nb_diag + n_obs) || (j < n_obs) || (j >= nb_diag + n_obs))
@@ -3773,8 +3732,8 @@ DynamicModel::writeOutput(ostream &output, const string &basename, bool block_de
         output << it + 1 << " ";
       output << "];" << endl;
 
-      int growth_param_index = get<1>(it.second);
-      if (growth_param_index >= 0)
+      if (int growth_param_index = get<1>(it.second);
+          growth_param_index >= 0)
         output << modstruct << "pac." << it.first << ".growth_neutrality_param_index = "
                << symbol_table.getTypeSpecificID(growth_param_index) + 1 << ";" << endl;
 
@@ -3971,16 +3930,14 @@ map<tuple<int, int, int>, expr_t>
 DynamicModel::collect_first_order_derivatives_endogenous()
 {
   map<tuple<int, int, int>, expr_t> endo_derivatives;
-  for (auto & first_derivative : derivatives[1])
-    {
-      if (getTypeByDerivID(first_derivative.first[1]) == SymbolType::endogenous)
-        {
-          int eq = first_derivative.first[0];
-          int var = symbol_table.getTypeSpecificID(getSymbIDByDerivID(first_derivative.first[1]));
-          int lag = getLagByDerivID(first_derivative.first[1]);
-          endo_derivatives[{ eq, var, lag }] = first_derivative.second;
-        }
-    }
+  for (auto & [indices, d1] : derivatives[1])
+    if (getTypeByDerivID(indices[1]) == SymbolType::endogenous)
+      {
+        int eq = indices[0];
+        int var = symbol_table.getTypeSpecificID(getSymbIDByDerivID(indices[1]));
+        int lag = getLagByDerivID(indices[1]);
+        endo_derivatives[{ eq, var, lag }] = d1;
+      }
   return endo_derivatives;
 }
 
@@ -4249,7 +4206,7 @@ DynamicModel::fillAutoregressiveMatrix(bool is_var) const
         var_model_table.getLhsOrigIds(it.first) : trend_component_model_table.getNonTargetLhs(it.first);
       for (auto eqn : it.second)
         {
-          auto *bopn = dynamic_cast<BinaryOpNode *>(equations[eqn]->arg2);
+          auto bopn = dynamic_cast<BinaryOpNode *>(equations[eqn]->arg2);
           bopn->fillAutoregressiveRow(i++, lhs, AR);
         }
       ARr[it.first] = AR;
@@ -4416,8 +4373,10 @@ DynamicModel::fillTrendComponentModelTableFromOrigModel() const
           // save lhs variables
           equations[eqn]->arg1->collectVARLHSVariable(lhs);
 
-          equations[eqn]->arg1->countDiffs() > 0 ?
-            diff_vec.push_back(true) : diff_vec.push_back(false);
+          if (equations[eqn]->arg1->countDiffs() > 0)
+            diff_vec.push_back(true);
+          else
+            diff_vec.push_back(false);
           if (diff_vec.back())
             {
               set<pair<int, int>> diff_set;
@@ -4475,8 +4434,7 @@ DynamicModel::addEquationsForVar()
 {
   if (var_model_table.empty())
     return;
-  map<string, pair<SymbolList, int>> var_symbol_list_and_order =
-    var_model_table.getSymbolListAndOrder();
+  auto var_symbol_list_and_order = var_model_table.getSymbolListAndOrder();
 
   // List of endogenous variables and the minimum lag value that must exist in the model equations
   map<string, int> var_endos_and_lags, model_endos_and_lags;
@@ -4486,13 +4444,12 @@ DynamicModel::addEquationsForVar()
         {
           vector<string> symbol_list = it.second.first.get_symbols();
           int order = it.second.second;
-          for (vector<string>::const_iterator it1 = symbol_list.begin();
-               it1 != symbol_list.end(); it1++)
+          for (auto & it1 : symbol_list)
             if (order > 2)
-              if (var_endos_and_lags.find(*it1) != var_endos_and_lags.end())
-                var_endos_and_lags[*it1] = min(var_endos_and_lags[*it1], -1*order);
+              if (var_endos_and_lags.find(it1) != var_endos_and_lags.end())
+                var_endos_and_lags[it1] = min(var_endos_and_lags[it1], -order);
               else
-                var_endos_and_lags[*it1] = -1*order;
+                var_endos_and_lags[it1] = -order;
           break;
         }
 
@@ -4505,23 +4462,20 @@ DynamicModel::addEquationsForVar()
     equation->getEndosAndMaxLags(model_endos_and_lags);
 
   int count = 0;
-  for (map<string, int>::const_iterator it = var_endos_and_lags.begin();
-       it != var_endos_and_lags.end(); it++)
-    {
-      map<string, int>::const_iterator it1 = model_endos_and_lags.find(it->first);
-      if (it1 == model_endos_and_lags.end())
-        cerr << "WARNING: Variable used in VAR that is not used in the model: " << it->first << endl;
-      else
-        if (it->second < it1->second)
-          {
-            int symb_id = symbol_table.getID(it->first);
-            expr_t newvar = AddVariable(symb_id, it->second);
-            expr_t auxvar = AddVariable(symbol_table.addVarModelEndoLagAuxiliaryVar(symb_id, it->second, newvar), 0);
-            addEquation(AddEqual(newvar, auxvar), -1);
-            addAuxEquation(AddEqual(newvar, auxvar));
-            count++;
-          }
-    }
+  for (auto & it : var_endos_and_lags)
+    if (auto it2 = model_endos_and_lags.find(it.first);
+        it2 == model_endos_and_lags.end())
+      cerr << "WARNING: Variable used in VAR that is not used in the model: " << it.first << endl;
+    else
+      if (it.second < it2->second)
+        {
+          int symb_id = symbol_table.getID(it.first);
+          expr_t newvar = AddVariable(symb_id, it.second);
+          expr_t auxvar = AddVariable(symbol_table.addVarModelEndoLagAuxiliaryVar(symb_id, it.second, newvar), 0);
+          addEquation(AddEqual(newvar, auxvar), -1);
+          addAuxEquation(AddEqual(newvar, auxvar));
+          count++;
+        }
 
   if (count > 0)
     cout << "Accounting for var_model lags not in model block: added "
@@ -4542,8 +4496,7 @@ DynamicModel::getUndiffLHSForPac(const string &aux_model_name,
   for (auto eqn : nontrend_eqnums)
     {
       int i = 0;
-      for (vector<int>::const_iterator it1 = eqnumber.begin();
-           it1 != eqnumber.end(); it1++, i++)
+      for (auto it1 = eqnumber.begin(); it1 != eqnumber.end(); ++it1, i++)
         if (*it1 == eqn)
           break;
 
@@ -4562,24 +4515,23 @@ DynamicModel::getUndiffLHSForPac(const string &aux_model_name,
         }
 
       bool printerr = false;
-      ExprNode::subst_table_t::const_iterator it1;
       expr_t node = nullptr;
       expr_t aux_var = lhs_expr_t.at(i);
-      for (it1 = diff_subst_table.begin(); it1 != diff_subst_table.end(); it1++)
-        if (it1->second == aux_var)
+      for (const auto &it : diff_subst_table)
+        if (it.second == aux_var)
           {
-            node = const_cast<expr_t>(it1->first);
+            node = const_cast<expr_t>(it.first);
             break;
           }
 
-      if (node == nullptr)
+      if (!node)
         {
           cerr << "Unexpected error encountered." << endl;
           exit(EXIT_FAILURE);
         }
 
       node = node->undiff();
-      it1 = diff_subst_table.find(node);
+      auto it1 = diff_subst_table.find(node);
       if (it1 == diff_subst_table.end())
         printerr = true;
 
@@ -4605,7 +4557,7 @@ DynamicModel::walkPacParameters(const string &name)
   int i = 0;
   for (auto & equation : equations)
     {
-      pair<int, int> lhs (-1, -1);
+      pair<int, int> lhs(-1, -1);
       pair<int, vector<tuple<int, bool, int>>> ec_params_and_vars;
       set<pair<int, pair<int, int>>> ar_params_and_vars;
       vector<tuple<int, int, int, double>> non_optim_vars_params_and_constants, optim_additive_vars_params_and_constants, additive_vars_params_and_constants;
@@ -4614,7 +4566,7 @@ DynamicModel::walkPacParameters(const string &name)
         {
           set<pair<int, int>> lhss;
           equation->arg1->collectDynamicVariables(SymbolType::endogenous, lhss);
-          lhs = *(lhss.begin());
+          lhs = *lhss.begin();
           int lhs_symb_id = lhs.first;
           int lhs_orig_symb_id = lhs_symb_id;
           if (symbol_table.isAuxiliaryVariable(lhs_orig_symb_id))
@@ -4627,7 +4579,7 @@ DynamicModel::walkPacParameters(const string &name)
               }
 
           auto arg2 = dynamic_cast<BinaryOpNode *>(equation->arg2);
-          if (arg2 == nullptr)
+          if (!arg2)
             {
               cerr << "Pac equation in incorrect format" << endl;
               exit(EXIT_FAILURE);
@@ -4635,10 +4587,10 @@ DynamicModel::walkPacParameters(const string &name)
           auto [optim_share_index, optim_part, non_optim_part, additive_part] =
             arg2->getPacOptimizingShareAndExprNodes(lhs_symb_id, lhs_orig_symb_id);
 
-          if (optim_part == nullptr)
+          if (!optim_part)
             {
               auto bopn = dynamic_cast<BinaryOpNode *>(equation->arg2);
-              if (bopn == nullptr)
+              if (!bopn)
                 {
                   cerr << "Error in PAC equation" << endl;
                   exit(EXIT_FAILURE);
@@ -4648,7 +4600,7 @@ DynamicModel::walkPacParameters(const string &name)
           else
             {
               auto bopn = dynamic_cast<BinaryOpNode *>(optim_part);
-              if (bopn == nullptr)
+              if (!bopn)
                 {
                   cerr << "Error in PAC equation" << endl;
                   exit(EXIT_FAILURE);
@@ -4657,7 +4609,7 @@ DynamicModel::walkPacParameters(const string &name)
               try
                 {
                   non_optim_vars_params_and_constants = non_optim_part->matchLinearCombinationOfVariables();
-                  if (additive_part != nullptr)
+                  if (additive_part)
                     additive_vars_params_and_constants = additive_part->matchLinearCombinationOfVariables();
                 }
               catch (ExprNode::MatchFailureException &e)
@@ -4668,7 +4620,7 @@ DynamicModel::walkPacParameters(const string &name)
                 }
             }
 
-          string eqtag = "";
+          string eqtag;
           for (auto & tag : equation_tags)
             if (tag.first == (&equation - &equations[0]))
               if (tag.second.first == "name")
@@ -4676,7 +4628,7 @@ DynamicModel::walkPacParameters(const string &name)
                   eqtag = tag.second.second;
                   break;
                 }
-          if (eqtag == "")
+          if (eqtag.empty())
             {
               cerr << "Every equation with a pac expectation must have been assigned an equation tag name" << endl;
               exit(EXIT_FAILURE);
@@ -4718,7 +4670,7 @@ DynamicModel::getPacMaxLag(const string &pac_model_name, map<pair<string, string
             exit(EXIT_FAILURE);
           }
 
-        string eqtag = "";
+        string eqtag;
         for (auto & tag : equation_tags)
           if (tag.first == (&equation - &equations[0]))
             if (tag.second.first == "name")
@@ -4737,10 +4689,10 @@ DynamicModel::getPacTargetSymbId(const string &pac_model_name) const
   for (auto & equation : equations)
     if (equation->containsPacExpectation(pac_model_name))
       {
-        pair<int, int> lhs (-1, -1);
+        pair<int, int> lhs(-1, -1);
         set<pair<int, int>> lhss;
         equation->arg1->collectDynamicVariables(SymbolType::endogenous, lhss);
-        lhs = *(lhss.begin());
+        lhs = *lhss.begin();
         int lhs_symb_id = lhs.first;
         int lhs_orig_symb_id = lhs_symb_id;
         if (symbol_table.isAuxiliaryVariable(lhs_symb_id))
@@ -4764,7 +4716,7 @@ DynamicModel::declarePacModelConsistentExpectationEndogs(const string &name)
   for (auto & equation : equations)
     if (equation->containsPacExpectation())
       {
-        string eqtag = "";
+        string eqtag;
         for (auto & tag : equation_tags)
           if (tag.first == (&equation - &equations[0]))
             if (tag.second.first == "name")
@@ -4772,7 +4724,7 @@ DynamicModel::declarePacModelConsistentExpectationEndogs(const string &name)
                 eqtag = tag.second.second;
                 break;
               }
-        if (eqtag == "")
+        if (eqtag.empty())
           {
             cerr << "Every equation with a pac expectation must have been assigned an equation tag name" << endl;
             exit(EXIT_FAILURE);
@@ -4837,8 +4789,8 @@ DynamicModel::addPacModelConsistentExpectationEquation(const string & name, int
       // Add diff nodes and eqs for pac_target_symb_id
       const VariableNode *target_base_diff_node;
       expr_t diff_node_to_search = AddDiff(AddVariable(pac_target_symb_id));
-      auto sit = diff_subst_table.find(diff_node_to_search);
-      if (sit != diff_subst_table.end())
+      if (auto sit = diff_subst_table.find(diff_node_to_search);
+          sit != diff_subst_table.end())
         target_base_diff_node = sit->second;
       else
         {
@@ -4908,7 +4860,7 @@ DynamicModel::fillPacModelInfo(const string &pac_model_name,
   bool nonstationary_vars_present = any_of(nonstationary.begin(), nonstationary.end(), [](bool b) { return b; }); // FIXME: use std::identity instead of an anonymous function when we upgrade to C++20
 
   int growth_param_index = -1;
-  if (growth != nullptr)
+  if (growth)
     growth_param_index = symbol_table.addSymbol(pac_model_name +
                                                 "_pac_growth_neutrality_correction",
                                                 SymbolType::parameter);
@@ -4952,7 +4904,7 @@ DynamicModel::fillPacModelInfo(const string &pac_model_name,
                                          AddVariable(lhsit, -i)));
             }
 
-      if (growth != nullptr)
+      if (growth)
         subExpr = AddPlus(subExpr,
                           AddTimes(AddVariable(growth_param_index), growth));
 
@@ -4967,15 +4919,15 @@ DynamicModel::substitutePacExpectation(const string & pac_model_name)
   for (auto & it : pac_expectation_substitution)
     if (it.first.first == pac_model_name)
       for (auto & equation : equations)
-        for (auto & tag : equation_tags)
-          if (tag.first == (&equation - &equations[0]))
-            if (tag.second.first == "name" && tag.second.second == it.first.second)
-              {
-                auto *substeq = dynamic_cast<BinaryOpNode *>(equation->substitutePacExpectation(pac_model_name, it.second));
-                assert(substeq != nullptr);
-                equation = substeq;
-                break;
-              }
+        for (auto & [tagged_eq, tag_pair] : equation_tags)
+          if (tagged_eq == (&equation - &equations[0]) &&
+              tag_pair.first == "name" && tag_pair.second == it.first.second)
+            {
+              auto substeq = dynamic_cast<BinaryOpNode *>(equation->substitutePacExpectation(pac_model_name, it.second));
+              assert(substeq);
+              equation = substeq;
+              break;
+            }
 }
 
 void
@@ -4995,12 +4947,11 @@ DynamicModel::computingPass(bool jacobianExo, int derivsOrder, int paramsDerivsO
 
   // Compute derivatives w.r. to all endogenous, and possibly exogenous and exogenous deterministic
   set<int> vars;
-  for (deriv_id_table_t::const_iterator it = deriv_id_table.begin();
-       it != deriv_id_table.end(); it++)
+  for (auto & it : deriv_id_table)
     {
-      SymbolType type = symbol_table.getType(it->first.first);
+      SymbolType type = symbol_table.getType(it.first.first);
       if (type == SymbolType::endogenous || (jacobianExo && (type == SymbolType::exogenous || type == SymbolType::exogenousDet)))
-        vars.insert(it->second);
+        vars.insert(it.second);
     }
 
   // Launch computations
@@ -5012,8 +4963,8 @@ DynamicModel::computingPass(bool jacobianExo, int derivsOrder, int paramsDerivsO
   if (derivsOrder > 1)
     {
       hessian_computed = true;
-      for (const auto &it : derivatives[2])
-        nonzero_hessian_eqs.insert(it.first[0]);
+      for (const auto &[indices, d2] : derivatives[2])
+        nonzero_hessian_eqs.insert(indices[0]);
     }
 
   if (paramsDerivsOrder > 0)
@@ -5025,7 +4976,7 @@ DynamicModel::computingPass(bool jacobianExo, int derivsOrder, int paramsDerivsO
   jacob_map_t contemporaneous_jacobian, static_jacobian;
   map<tuple<int, int, int>, expr_t> first_order_endo_derivatives;
   // for each block contains pair<Size, Feddback_variable>
-  vector<pair<int, int> > blocks;
+  vector<pair<int, int>> blocks;
   vector<unsigned int> n_static, n_forward, n_backward, n_mixed;
 
   if (linear_decomposition)
@@ -5062,12 +5013,10 @@ DynamicModel::computingPass(bool jacobianExo, int derivsOrder, int paramsDerivsO
       global_temporary_terms = true;
       if (!no_tmp_terms)
         computeTemporaryTermsOrdered();
-
     }
 
   if (block)
     {
-
       evaluateAndReduceJacobian(eval_context, contemporaneous_jacobian, static_jacobian, dynamic_jacobian, cutoff, false);
 
       computeNonSingularNormalization(contemporaneous_jacobian, cutoff, static_jacobian, dynamic_jacobian);
@@ -5138,8 +5087,7 @@ DynamicModel::computeXrefs()
     }
 
   i = 0;
-  for (map<int, ExprNode::EquationInfo>::const_iterator it = xrefs.begin();
-       it != xrefs.end(); it++, i++)
+  for (auto it = xrefs.begin(); it != xrefs.end(); ++it, i++)
     {
       computeRevXref(xref_param, it->second.param, i);
       computeRevXref(xref_endo, it->second.endo, i);
@@ -5169,8 +5117,7 @@ DynamicModel::writeXrefs(ostream &output) const
          << "M_.xref1.exo = cell(1, M_.eq_nbr);" << endl
          << "M_.xref1.exo_det = cell(1, M_.eq_nbr);" << endl;
   int i = 1;
-  for (auto it = xrefs.begin();
-       it != xrefs.end(); it++, i++)
+  for (auto it = xrefs.begin(); it != xrefs.end(); ++it, i++)
     {
       output << "M_.xref1.param{" << i << "} = [ ";
       for (const auto & it1 : it->second.param)
@@ -5216,12 +5163,11 @@ DynamicModel::writeRevXrefs(ostream &output, const map<pair<int, int>, set<int>>
       else
         last_tsid = tsid;
 
-      for (auto it1 = it.second.begin();
-           it1 != it.second.end(); it1++)
+      for (const auto &it1 : it.second)
         if (type == "param")
-          output << *it1 + 1 << " ";
+          output << it1 + 1 << " ";
         else
-          output << "struct('shift', " << it.first.second << ", 'eq', " << *it1+1 << ");";
+          output << "struct('shift', " << it.first.second << ", 'eq', " << it1+1 << ");";
       output << "];" << endl;
     }
 }
@@ -5256,12 +5202,9 @@ DynamicModel::get_Derivatives(int block)
               if (dynamic_jacobian.find({ lag, eqr, varr }) != dynamic_jacobian.end())
                 {
                   bool OK = true;
-                  auto its = Derivatives.find({ lag, eq, var, eqr, varr });
-                  if (its != Derivatives.end())
-                    {
-                      if (its->second == 2)
-                        OK = false;
-                    }
+                  if (auto its = Derivatives.find({ lag, eq, var, eqr, varr });
+                      its != Derivatives.end() && its->second == 2)
+                    OK = false;
 
                   if (OK)
                     {
@@ -5360,16 +5303,16 @@ DynamicModel::collect_block_first_order_derivatives()
   exo_max_leadlag_block = vector<pair<int, int>>(nb_blocks, { 0, 0 });
   exo_det_max_leadlag_block = vector<pair<int, int>>(nb_blocks, { 0, 0 });
   max_leadlag_block = vector<pair<int, int>>(nb_blocks, { 0, 0 });
-  for (auto & first_derivative : derivatives[1])
+  for (auto & [indices, d1] : derivatives[1])
     {
-      int eq = first_derivative.first[0];
-      int var = symbol_table.getTypeSpecificID(getSymbIDByDerivID(first_derivative.first[1]));
-      int lag = getLagByDerivID(first_derivative.first[1]);
+      int eq = indices[0];
+      int var = symbol_table.getTypeSpecificID(getSymbIDByDerivID(indices[1]));
+      int lag = getLagByDerivID(indices[1]);
       int block_eq = equation_2_block[eq];
       int block_var = 0;
       derivative_t tmp_derivative;
       lag_var_t lag_var;
-      switch (getTypeByDerivID(first_derivative.first[1]))
+      switch (getTypeByDerivID(indices[1]))
         {
         case SymbolType::endogenous:
           block_var = variable_2_block[var];
@@ -5390,20 +5333,18 @@ DynamicModel::collect_block_first_order_derivatives()
               if (lag > 0 && lag > other_endo_max_leadlag_block[block_eq].second)
                 other_endo_max_leadlag_block[block_eq] = { other_endo_max_leadlag_block[block_eq].first, lag };
               tmp_derivative = derivative_other_endo[block_eq];
-              {
-                auto it = block_other_endo_index.find(block_eq);
-                if (it == block_other_endo_index.end())
-                  block_other_endo_index[block_eq][var] = 0;
-                else
+
+              if (auto it = block_other_endo_index.find(block_eq);
+                  it == block_other_endo_index.end())
+                block_other_endo_index[block_eq][var] = 0;
+              else
+                if (auto it1 = it->second.find(var);
+                    it1 == it->second.end())
                   {
-                    auto it1 = it->second.find(var);
-                    if (it1 == it->second.end())
-                      {
-                        int size = block_other_endo_index[block_eq].size();
-                        block_other_endo_index[block_eq][var] = size;
-                      }
+                    int size = block_other_endo_index[block_eq].size();
+                    block_other_endo_index[block_eq][var] = size;
                   }
-              }
+
               tmp_derivative[{ lag, eq, var }] = derivatives[1][{ eq, getDerivID(symbol_table.getID(SymbolType::endogenous, var), lag) }];
               derivative_other_endo[block_eq] = tmp_derivative;
               lag_var = other_endo_block[block_eq];
@@ -5419,20 +5360,18 @@ DynamicModel::collect_block_first_order_derivatives()
           if (lag > 0 && lag > exo_max_leadlag_block[block_eq].second)
             exo_max_leadlag_block[block_eq] = { exo_max_leadlag_block[block_eq].first, lag };
           tmp_derivative = derivative_exo[block_eq];
-          {
-            auto it = block_exo_index.find(block_eq);
-            if (it == block_exo_index.end())
-              block_exo_index[block_eq][var] = 0;
-            else
+
+          if (auto it = block_exo_index.find(block_eq);
+              it == block_exo_index.end())
+            block_exo_index[block_eq][var] = 0;
+          else
+            if (auto it1 = it->second.find(var);
+                it1 == it->second.end())
               {
-                auto it1 = it->second.find(var);
-                if (it1 == it->second.end())
-                  {
-                    int size = block_exo_index[block_eq].size();
-                    block_exo_index[block_eq][var] = size;
-                  }
+                int size = block_exo_index[block_eq].size();
+                block_exo_index[block_eq][var] = size;
               }
-          }
+
           tmp_derivative[{ lag, eq, var }] = derivatives[1][{ eq, getDerivID(symbol_table.getID(SymbolType::exogenous, var), lag) }];
           derivative_exo[block_eq] = tmp_derivative;
           lag_var = exo_block[block_eq];
@@ -5447,20 +5386,18 @@ DynamicModel::collect_block_first_order_derivatives()
           if (lag > 0 && lag > exo_det_max_leadlag_block[block_eq].second)
             exo_det_max_leadlag_block[block_eq] = { exo_det_max_leadlag_block[block_eq].first, lag };
           tmp_derivative = derivative_exo_det[block_eq];
-          {
-            auto it = block_det_exo_index.find(block_eq);
-            if (it == block_det_exo_index.end())
-              block_det_exo_index[block_eq][var] = 0;
-            else
+
+          if (auto it = block_det_exo_index.find(block_eq);
+              it == block_det_exo_index.end())
+            block_det_exo_index[block_eq][var] = 0;
+          else
+            if (auto it1 = it->second.find(var);
+                it1 == it->second.end())
               {
-                auto it1 = it->second.find(var);
-                if (it1 == it->second.end())
-                  {
-                    int size = block_det_exo_index[block_eq].size();
-                    block_det_exo_index[block_eq][var] = size;
-                  }
+                int size = block_det_exo_index[block_eq].size();
+                block_det_exo_index[block_eq][var] = size;
               }
-          }
+
           tmp_derivative[{ lag, eq, var }] = derivatives[1][{ eq, getDerivID(symbol_table.getID(SymbolType::exogenous, var), lag) }];
           derivative_exo_det[block_eq] = tmp_derivative;
           lag_var = exo_det_block[block_eq];
@@ -5477,7 +5414,6 @@ DynamicModel::collect_block_first_order_derivatives()
       if (lag > 0 && lag > max_leadlag_block[block_eq].second)
         max_leadlag_block[block_eq] = { max_leadlag_block[block_eq].first, lag };
     }
-
 }
 
 void
@@ -5533,7 +5469,7 @@ DynamicModel::writeDynamicFile(const string &basename, bool block, bool linear_d
 }
 
 void
-DynamicModel::writeSetAuxiliaryVariables(const string &basename, const bool julia) const
+DynamicModel::writeSetAuxiliaryVariables(const string &basename, bool julia) const
 {
   ostringstream output_func_body;
   writeAuxVarRecursiveDefinitions(output_func_body, ExprNodeOutputType::matlabDseries);
@@ -5570,15 +5506,14 @@ DynamicModel::writeAuxVarRecursiveDefinitions(ostream &output, ExprNodeOutputTyp
   deriv_node_temp_terms_t tef_terms;
   temporary_terms_t temporary_terms;
   temporary_terms_idxs_t temporary_terms_idxs;
-  for (auto aux_equation : aux_equations)
-    if (dynamic_cast<ExprNode *>(aux_equation)->containsExternalFunction())
-      dynamic_cast<ExprNode *>(aux_equation)->writeExternalFunctionOutput(output, output_type,
-                                                                              temporary_terms,
-                                                                              temporary_terms_idxs,
-                                                                              tef_terms);
-  for (auto aux_equation : aux_equations)
-    {
-      dynamic_cast<ExprNode *>(aux_equation)->writeOutput(output, output_type, temporary_terms, temporary_terms_idxs, tef_terms);
+  for (auto aux_eq : aux_equations)
+    if (auto aux_eq2 = dynamic_cast<ExprNode *>(aux_eq);
+        aux_eq2->containsExternalFunction())
+      aux_eq2->writeExternalFunctionOutput(output, output_type, temporary_terms,
+                                           temporary_terms_idxs, tef_terms);
+  for (auto aux_eq : aux_equations)
+    {
+      dynamic_cast<ExprNode *>(aux_eq)->writeOutput(output, output_type, temporary_terms, temporary_terms_idxs, tef_terms);
       output << ";" << endl;
     }
 }
@@ -5600,8 +5535,8 @@ DynamicModel::computeRamseyPolicyFOCs(const StaticModel &static_model)
   int i;
   for (i = 0; i < static_cast<int>(equations.size()); i++)
     {
-      auto *substeq = dynamic_cast<BinaryOpNode *>(equations[i]->addMultipliersToConstraints(i));
-      assert(substeq != nullptr);
+      auto substeq = dynamic_cast<BinaryOpNode *>(equations[i]->addMultipliersToConstraints(i));
+      assert(substeq);
       equations[i] = substeq;
     }
   cout << "Ramsey Problem: added " << i << " Multipliers." << endl;
@@ -5638,7 +5573,7 @@ DynamicModel::computeRamseyPolicyFOCs(const StaticModel &static_model)
     for (int lag = -max_eq_lag; lag <= max_eq_lead; lag++)
       {
         expr_t dfpower = nullptr;
-        std::stringstream lagstream;
+        stringstream lagstream;
         lagstream << abs(lag);
         if (lag < 0)
           dfpower = AddNonNegativeConstant(lagstream.str());
@@ -5657,11 +5592,10 @@ DynamicModel::computeRamseyPolicyFOCs(const StaticModel &static_model)
 
   //Compute derivatives and overwrite equations
   vector<expr_t> neweqs;
-  for (deriv_id_table_t::const_iterator it = deriv_id_table.begin();
-       it != deriv_id_table.end(); it++)
+  for (auto & it : deriv_id_table)
     // For all endogenous variables with zero lag
-    if (symbol_table.getType(it->first.first)  == SymbolType::endogenous && it->first.second == 0)
-      neweqs.push_back(AddEqual(equations[0]->getNonZeroPartofEquation()->getDerivative(it->second), Zero));
+    if (symbol_table.getType(it.first.first) == SymbolType::endogenous && it.first.second == 0)
+      neweqs.push_back(AddEqual(equations[0]->getNonZeroPartofEquation()->getDerivative(it.second), Zero));
 
   // Add new equations
   equations.clear();
@@ -5710,14 +5644,14 @@ DynamicModel::expandEqTags()
 
   for (int eq = 0; eq < static_cast<int>(equations.size()); eq++)
     if (existing_tags.find(eq) == existing_tags.end())
-      if (auto lhs_expr = dynamic_cast<VariableNode *>(equations[eq]->arg1); lhs_expr && equation_tags_xref.find(pair("name", symbol_table.getName(lhs_expr->symb_id))) == equation_tags_xref.end())
+      if (auto lhs_expr = dynamic_cast<VariableNode *>(equations[eq]->arg1); lhs_expr && equation_tags_xref.find({ "name", symbol_table.getName(lhs_expr->symb_id)}) == equation_tags_xref.end())
         {
-          equation_tags.push_back(pair(eq, pair("name", symbol_table.getName(lhs_expr->symb_id))));
+          equation_tags.emplace_back(eq, pair("name", symbol_table.getName(lhs_expr->symb_id)));
           equation_tags_xref.emplace(pair("name", symbol_table.getName(lhs_expr->symb_id)), eq);
         }
-      else if (equation_tags_xref.find(pair("name",to_string(eq+1))) == equation_tags_xref.end())
+      else if (equation_tags_xref.find({ "name",to_string(eq+1) }) == equation_tags_xref.end())
         {
-          equation_tags.push_back(pair(eq, pair("name", to_string(eq+1))));
+          equation_tags.emplace_back(eq, pair("name", to_string(eq+1)));
           equation_tags_xref.emplace(pair("name", to_string(eq+1)), eq);
         }
       else
@@ -5912,12 +5846,11 @@ DynamicModel::computeDynJacobianCols(bool jacobianExo)
      and fill the dynamic columns for exogenous and exogenous deterministic */
   map<pair<int, int>, int> ordered_dyn_endo;
 
-  for (deriv_id_table_t::const_iterator it = deriv_id_table.begin();
-       it != deriv_id_table.end(); it++)
+  for (auto & it : deriv_id_table)
     {
-      const int &symb_id = it->first.first;
-      const int &lag = it->first.second;
-      const int &deriv_id = it->second;
+      int symb_id = it.first.first;
+      int lag = it.first.second;
+      int deriv_id = it.second;
       SymbolType type = symbol_table.getType(symb_id);
       int tsid = symbol_table.getTypeSpecificID(symb_id);
 
@@ -5950,9 +5883,8 @@ DynamicModel::computeDynJacobianCols(bool jacobianExo)
 
   // Fill in dynamic jacobian columns for endogenous
   int sorted_id = 0;
-  for (map<pair<int, int>, int>::const_iterator it = ordered_dyn_endo.begin();
-       it != ordered_dyn_endo.end(); it++)
-    dyn_jacobian_cols_table[it->second] = sorted_id++;
+  for (auto & it : ordered_dyn_endo)
+    dyn_jacobian_cols_table[it.second] = sorted_id++;
 
   // Set final value for dynJacobianColsNbr
   if (jacobianExo)
@@ -5962,8 +5894,8 @@ DynamicModel::computeDynJacobianCols(bool jacobianExo)
 int
 DynamicModel::getDynJacobianCol(int deriv_id) const noexcept(false)
 {
-  auto it = dyn_jacobian_cols_table.find(deriv_id);
-  if (it == dyn_jacobian_cols_table.end())
+  if (auto it = dyn_jacobian_cols_table.find(deriv_id);
+      it == dyn_jacobian_cols_table.end())
     throw UnknownDerivIDException();
   else
     return it->second;
@@ -5972,10 +5904,9 @@ DynamicModel::getDynJacobianCol(int deriv_id) const noexcept(false)
 void
 DynamicModel::testTrendDerivativesEqualToZero(const eval_context_t &eval_context)
 {
-  for (deriv_id_table_t::const_iterator it = deriv_id_table.begin();
-       it != deriv_id_table.end(); it++)
-    if (symbol_table.getType(it->first.first) == SymbolType::trend
-        || symbol_table.getType(it->first.first) == SymbolType::logTrend)
+  for (auto &it : deriv_id_table)
+    if (symbol_table.getType(it.first.first) == SymbolType::trend
+        || symbol_table.getType(it.first.first) == SymbolType::logTrend)
       for (int eq = 0; eq < static_cast<int>(equations.size()); eq++)
         {
           expr_t homogeneq = AddMinus(equations[eq]->arg1,
@@ -5985,18 +5916,17 @@ DynamicModel::testTrendDerivativesEqualToZero(const eval_context_t &eval_context
           if (fabs(homogeneq->eval(eval_context)) > zero_band)
             {
               expr_t testeq = AddLog(homogeneq); // F = log(lhs-rhs)
-              testeq = testeq->getDerivative(it->second); // d F / d Trend
-              for (deriv_id_table_t::const_iterator endogit = deriv_id_table.begin();
-                   endogit != deriv_id_table.end(); endogit++)
-                if (symbol_table.getType(endogit->first.first) == SymbolType::endogenous)
+              testeq = testeq->getDerivative(it.second); // d F / d Trend
+              for (auto & endogit : deriv_id_table)
+                if (symbol_table.getType(endogit.first.first) == SymbolType::endogenous)
                   {
-                    double nearZero = testeq->getDerivative(endogit->second)->eval(eval_context); // eval d F / d Trend d Endog
+                    double nearZero = testeq->getDerivative(endogit.second)->eval(eval_context); // eval d F / d Trend d Endog
                     if (fabs(nearZero) > balanced_growth_test_tol)
                       {
                         cerr << "ERROR: trends not compatible with balanced growth path; the second-order cross partial of equation " << eq + 1 << " (line "
                              << equations_lineno[eq] << ") w.r.t. trend variable "
-                             << symbol_table.getName(it->first.first) << " and endogenous variable "
-                             << symbol_table.getName(endogit->first.first) << " is not null (abs. value = "
+                             << symbol_table.getName(it.first.first) << " and endogenous variable "
+                             << symbol_table.getName(endogit.first.first) << " is not null (abs. value = "
                              << fabs(nearZero) << "). If you are confident that your trends are correctly specified, you can raise the value of option 'balanced_growth_test_tol' in the 'model' block." << endl;
                         exit(EXIT_FAILURE);
                       }
@@ -6027,10 +5957,9 @@ DynamicModel::writeParamsDerivativesFile(const string &basename, bool julia) con
   for (const auto &it : params_derivs_temporary_terms)
     writeTemporaryTerms(it.second, temp_term_union, params_derivs_temporary_terms_idxs, tt_output, output_type, tef_terms);
 
-  for (const auto & residuals_params_derivative : params_derivatives.find({ 0, 1 })->second)
+  for (const auto & [indices, d1] : params_derivatives.find({ 0, 1 })->second)
     {
-      auto [eq, param] = vectorToTuple<2>(residuals_params_derivative.first);
-      expr_t d1 = residuals_params_derivative.second;
+      auto [eq, param] = vectorToTuple<2>(indices);
 
       int param_col = symbol_table.getTypeSpecificID(getSymbIDByDerivID(param)) + 1;
 
@@ -6040,10 +5969,9 @@ DynamicModel::writeParamsDerivativesFile(const string &basename, bool julia) con
       rp_output << ";" << endl;
     }
 
-  for (const auto & jacobian_params_derivative : params_derivatives.find({ 1, 1 })->second)
+  for (const auto & [indices, d2] : params_derivatives.find({ 1, 1 })->second)
     {
-      auto [eq, var, param] = vectorToTuple<3>(jacobian_params_derivative.first);
-      expr_t d2 = jacobian_params_derivative.second;
+      auto [eq, var, param] = vectorToTuple<3>(indices);
 
       int var_col = getDynJacobianCol(var) + 1;
       int param_col = symbol_table.getTypeSpecificID(getSymbIDByDerivID(param)) + 1;
@@ -6055,10 +5983,9 @@ DynamicModel::writeParamsDerivativesFile(const string &basename, bool julia) con
     }
 
   int i = 1;
-  for (const auto &it : params_derivatives.find({ 0, 2 })->second)
+  for (const auto &[indices, d2] : params_derivatives.find({ 0, 2 })->second)
     {
-      auto [eq, param1, param2] = vectorToTuple<3>(it.first);
-      expr_t d2 = it.second;
+      auto [eq, param1, param2] = vectorToTuple<3>(indices);
 
       int param1_col = symbol_table.getTypeSpecificID(getSymbIDByDerivID(param1)) + 1;
       int param2_col = symbol_table.getTypeSpecificID(getSymbIDByDerivID(param2)) + 1;
@@ -6094,10 +6021,9 @@ DynamicModel::writeParamsDerivativesFile(const string &basename, bool julia) con
     }
 
   i = 1;
-  for (const auto &it : params_derivatives.find({ 1, 2 })->second)
+  for (const auto &[indices, d2] : params_derivatives.find({ 1, 2 })->second)
     {
-      auto [eq, var, param1, param2] = vectorToTuple<4>(it.first);
-      expr_t d2 = it.second;
+      auto [eq, var, param1, param2] = vectorToTuple<4>(indices);
 
       int var_col = getDynJacobianCol(var) + 1;
       int param1_col = symbol_table.getTypeSpecificID(getSymbIDByDerivID(param1)) + 1;
@@ -6138,10 +6064,9 @@ DynamicModel::writeParamsDerivativesFile(const string &basename, bool julia) con
     }
 
   i = 1;
-  for (const auto &it : params_derivatives.find({ 2, 1 })->second)
+  for (const auto &[indices, d2] : params_derivatives.find({ 2, 1 })->second)
     {
-      auto [eq, var1, var2, param] = vectorToTuple<4>(it.first);
-      expr_t d2 = it.second;
+      auto [eq, var1, var2, param] = vectorToTuple<4>(indices);
 
       int var1_col = getDynJacobianCol(var1) + 1;
       int var2_col = getDynJacobianCol(var2) + 1;
@@ -6182,10 +6107,9 @@ DynamicModel::writeParamsDerivativesFile(const string &basename, bool julia) con
     }
 
   i = 1;
-  for (const auto &it : params_derivatives.find({ 3, 1 })->second)
+  for (const auto &[indices, d2] : params_derivatives.find({ 3, 1 })->second)
     {
-      auto [eq, var1, var2, var3, param] = vectorToTuple<5>(it.first);
-      expr_t d2 = it.second;
+      auto [eq, var1, var2, var3, param] = vectorToTuple<5>(indices);
 
       int var1_col = getDynJacobianCol(var1) + 1;
       int var2_col = getDynJacobianCol(var2) + 1;
@@ -6337,13 +6261,13 @@ DynamicModel::writeParamsDerivativesFile(const string &basename, bool julia) con
 }
 
 void
-DynamicModel::writeLatexFile(const string &basename, const bool write_equation_tags) const
+DynamicModel::writeLatexFile(const string &basename, bool write_equation_tags) const
 {
   writeLatexModelFile(basename, "dynamic", ExprNodeOutputType::latexDynamicModel, write_equation_tags);
 }
 
 void
-DynamicModel::writeLatexOriginalFile(const string &basename, const bool write_equation_tags) const
+DynamicModel::writeLatexOriginalFile(const string &basename, bool write_equation_tags) const
 {
   writeLatexModelFile(basename, "original", ExprNodeOutputType::latexDynamicModel, write_equation_tags);
 }
@@ -6436,8 +6360,8 @@ DynamicModel::substituteLeadLagInternal(AuxVarType type, bool deterministic_mode
           cerr << "DynamicModel::substituteLeadLagInternal: impossible case" << endl;
           exit(EXIT_FAILURE);
         }
-      auto *substeq = dynamic_cast<BinaryOpNode *>(subst);
-      assert(substeq != nullptr);
+      auto substeq = dynamic_cast<BinaryOpNode *>(subst);
+      assert(substeq);
       equation = substeq;
     }
 
@@ -6516,9 +6440,9 @@ DynamicModel::findPacExpectationEquationNumbers(vector<int> &eqnumbers) const
   int i = 0;
   for (auto & equation : equations)
     {
-      if (equation->containsPacExpectation())
-        if (find(eqnumbers.begin(), eqnumbers.end(), i) == eqnumbers.end())
-          eqnumbers.push_back(i);
+      if (equation->containsPacExpectation() &&
+          find(eqnumbers.begin(), eqnumbers.end(), i) == eqnumbers.end())
+        eqnumbers.push_back(i);
       i++;
     }
 }
@@ -6565,9 +6489,9 @@ DynamicModel::substituteUnaryOps(const vector<int> &eqnumbers)
   // Substitute in equations
   for (auto & equation : equations)
     {
-      auto *substeq = dynamic_cast<BinaryOpNode *>(equation->
-                                                   substituteUnaryOpNodes(nodes, subst_table, neweqs));
-      assert(substeq != nullptr);
+      auto substeq = dynamic_cast<BinaryOpNode *>(equation->
+                                                  substituteUnaryOpNodes(nodes, subst_table, neweqs));
+      assert(substeq);
       equation = substeq;
     }
 
@@ -6608,7 +6532,7 @@ DynamicModel::substituteDiff(vector<expr_t> &pac_growth)
     equation->findDiffNodes(diff_nodes);
 
   for (const auto & gv : pac_growth)
-    if (gv != nullptr)
+    if (gv)
       gv->findDiffNodes(diff_nodes);
 
   // Substitute in model local variables
@@ -6619,14 +6543,14 @@ DynamicModel::substituteDiff(vector<expr_t> &pac_growth)
   // Substitute in equations
   for (auto & equation : equations)
     {
-      auto *substeq = dynamic_cast<BinaryOpNode *>(equation->
-                                                   substituteDiff(diff_nodes, diff_subst_table, neweqs));
-      assert(substeq != nullptr);
+      auto substeq = dynamic_cast<BinaryOpNode *>(equation->
+                                                  substituteDiff(diff_nodes, diff_subst_table, neweqs));
+      assert(substeq);
       equation = substeq;
     }
 
   for (auto & it : pac_growth)
-    if (it != nullptr)
+    if (it)
       it = it->substituteDiff(diff_nodes, diff_subst_table, neweqs);
 
   // Add new equations
@@ -6655,8 +6579,8 @@ DynamicModel::substituteExpectation(bool partial_information_model)
   // Substitute in equations
   for (auto & equation : equations)
     {
-      auto *substeq = dynamic_cast<BinaryOpNode *>(equation->substituteExpectation(subst_table, neweqs, partial_information_model));
-      assert(substeq != nullptr);
+      auto substeq = dynamic_cast<BinaryOpNode *>(equation->substituteExpectation(subst_table, neweqs, partial_information_model));
+      assert(substeq);
       equation = substeq;
     }
 
@@ -6684,8 +6608,8 @@ DynamicModel::transformPredeterminedVariables()
 
   for (auto & equation : equations)
     {
-      auto *substeq = dynamic_cast<BinaryOpNode *>(equation->decreaseLeadsLagsPredeterminedVariables());
-      assert(substeq != nullptr);
+      auto substeq = dynamic_cast<BinaryOpNode *>(equation->decreaseLeadsLagsPredeterminedVariables());
+      assert(substeq);
       equation = substeq;
     }
 }
@@ -6698,15 +6622,15 @@ DynamicModel::detrendEquations()
        it != nonstationary_symbols_map.crend(); ++it)
     for (auto & equation : equations)
       {
-        auto *substeq = dynamic_cast<BinaryOpNode *>(equation->detrend(it->first, it->second.first, it->second.second));
-        assert(substeq != nullptr);
+        auto substeq = dynamic_cast<BinaryOpNode *>(equation->detrend(it->first, it->second.first, it->second.second));
+        assert(substeq);
         equation = dynamic_cast<BinaryOpNode *>(substeq);
       }
 
   for (auto & equation : equations)
     {
-      BinaryOpNode *substeq = dynamic_cast<BinaryOpNode *>(equation->removeTrendLeadLag(trend_symbols_map));
-      assert(substeq != nullptr);
+      auto substeq = dynamic_cast<BinaryOpNode *>(equation->removeTrendLeadLag(trend_symbols_map));
+      assert(substeq);
       equation = dynamic_cast<BinaryOpNode *>(substeq);
     }
 }
@@ -6716,8 +6640,8 @@ DynamicModel::removeTrendVariableFromEquations()
 {
   for (auto & equation : equations)
     {
-      auto *substeq = dynamic_cast<BinaryOpNode *>(equation->replaceTrendVar());
-      assert(substeq != nullptr);
+      auto substeq = dynamic_cast<BinaryOpNode *>(equation->replaceTrendVar());
+      assert(substeq);
       equation = dynamic_cast<BinaryOpNode *>(substeq);
     }
 }
@@ -6735,8 +6659,8 @@ DynamicModel::fillEvalContext(eval_context_t &eval_context) const
   for (auto aux_equation : aux_equations)
     {
       assert(aux_equation->op_code == BinaryOpcode::equal);
-      auto *auxvar = dynamic_cast<VariableNode *>(aux_equation->arg1);
-      assert(auxvar != nullptr);
+      auto auxvar = dynamic_cast<VariableNode *>(aux_equation->arg1);
+      assert(auxvar);
       try
         {
           double val = aux_equation->arg2->eval(eval_context);
@@ -6765,9 +6689,8 @@ DynamicModel::fillEvalContext(eval_context_t &eval_context) const
 
   //Third, trend variables
   vector <int> trendVars = symbol_table.getTrendVarIds();
-  for (vector <int>::const_iterator it = trendVars.begin();
-       it != trendVars.end(); it++)
-    eval_context[*it] = 2;                               //not <= 0 bc of log, not 1 bc of powers
+  for (int & trendVar : trendVars)
+    eval_context[trendVar] = 2;  //not <= 0 bc of log, not 1 bc of powers
 }
 
 bool
@@ -6786,8 +6709,8 @@ DynamicModel::isModelLocalVariableUsed() const
 void
 DynamicModel::addStaticOnlyEquation(expr_t eq, int lineno, const vector<pair<string, string>> &eq_tags)
 {
-  auto *beq = dynamic_cast<BinaryOpNode *>(eq);
-  assert(beq != nullptr && beq->op_code == BinaryOpcode::equal);
+  auto beq = dynamic_cast<BinaryOpNode *>(eq);
+  assert(beq && beq->op_code == BinaryOpcode::equal);
 
   vector<pair<string, string>> soe_eq_tags;
   for (const auto & eq_tag : eq_tags)
@@ -6907,11 +6830,12 @@ DynamicModel::writeJsonAST(ostream &output) const
         {
           output << R"(, "tags": {)";
           int i = 0;
-          for (vector<pair<string, string>>::const_iterator it = eqtags.begin(); it != eqtags.end(); it++, i++)
+          for (const auto &[name, value] : eqtags)
             {
               if (i != 0)
                 output << ", ";
-              output << R"(")" << it->first << R"(": ")" << it->second << R"(")";
+              output << R"(")" << name << R"(": ")" << value << R"(")";
+              i++;
             }
           output << "}";
           eqtags.clear();
@@ -6947,16 +6871,14 @@ DynamicModel::writeJsonVariableMapping(ostream &output) const
 void
 DynamicModel::writeJsonXrefsHelper(ostream &output, const map<pair<int, int>, set<int>> &xrefs) const
 {
-  for (auto it = xrefs.begin();
-       it != xrefs.end(); it++)
+  for (auto it = xrefs.begin(); it != xrefs.end(); ++it)
     {
       if (it != xrefs.begin())
         output << ", ";
       output << R"({"name": ")" << symbol_table.getName(it->first.first) << R"(")"
              << R"(, "shift": )" << it->first.second
              << R"(, "equations": [)";
-      for (auto it1 = it->second.begin();
-           it1 != it->second.end(); it1++)
+      for (auto it1 = it->second.begin(); it1 != it->second.end(); ++it1)
         {
           if (it1 != it->second.begin())
             output << ", ";
@@ -6977,7 +6899,7 @@ DynamicModel::writeJsonXrefs(ostream &output) const
   writeJsonXrefsHelper(output, xref_endo);
   output << "]"
          << R"(, "exogenous": [)";
-    writeJsonXrefsHelper(output, xref_exo);
+  writeJsonXrefsHelper(output, xref_exo);
   output << "]"
          << R"(, "exogenous_deterministic": [)";
   writeJsonXrefsHelper(output, xref_exo_det);
@@ -6999,18 +6921,18 @@ DynamicModel::writeJsonDynamicModelInfo(ostream &output) const
          << R"("lead_lag_incidence": [)";
   // Loop on endogenous variables
   int nstatic = 0,
-    nfwrd   = 0,
-    npred   = 0,
-    nboth   = 0;
+    nfwrd = 0,
+    npred = 0,
+    nboth = 0;
   for (int endoID = 0; endoID < symbol_table.endo_nbr(); endoID++)
     {
       if (endoID != 0)
         output << ",";
       output << "[";
       int sstatic = 1,
-        sfwrd   = 0,
-        spred   = 0,
-        sboth   = 0;
+        sfwrd = 0,
+        spred = 0,
+        sboth = 0;
       // Loop on periods
       for (int lag = -max_endo_lag; lag <= max_endo_lead; lag++)
         {
@@ -7170,7 +7092,7 @@ DynamicModel::writeJsonParamsDerivativesFile(ostream &output, bool writeDetails)
             << R"(, "nparamcols": )" << symbol_table.param_nbr()
             << R"(, "entries": [)";
   auto &rp = params_derivatives.find({ 0, 1 })->second;
-  for (auto it = rp.begin(); it != rp.end(); it++)
+  for (auto it = rp.begin(); it != rp.end(); ++it)
     {
       if (it != rp.begin())
         rp_output << ", ";
@@ -7202,7 +7124,7 @@ DynamicModel::writeJsonParamsDerivativesFile(ostream &output, bool writeDetails)
             << R"(, "nparamcols": )" << symbol_table.param_nbr()
             << R"(, "entries": [)";
   auto &gp = params_derivatives.find({ 1, 1 })->second;
-  for (auto it = gp.begin(); it != gp.end(); it++)
+  for (auto it = gp.begin(); it != gp.end(); ++it)
     {
       if (it != gp.begin())
         gp_output << ", ";
diff --git a/src/DynamicModel.hh b/src/DynamicModel.hh
index b7973aa4a728a988ec8c8e14973219801090b6f4..dc615173f894f1bd1f53663a8e4592128592dc6f 100644
--- a/src/DynamicModel.hh
+++ b/src/DynamicModel.hh
@@ -106,7 +106,7 @@ private:
   /*! Set by computeDerivID()s and computeDynJacobianCols() */
   int dynJacobianColsNbr{0};
   //! Temporary terms for block decomposed models
-  vector< vector<temporary_terms_t>> v_temporary_terms;
+  vector<vector<temporary_terms_t>> v_temporary_terms;
 
   vector<temporary_terms_inuse_t> v_temporary_terms_inuse;
 
@@ -123,7 +123,7 @@ private:
   void writeDynamicJuliaFile(const string &dynamic_basename) const;
   //! Writes dynamic model file (C version)
   /*! \todo add third derivatives handling */
-  void writeDynamicCFile(const string &basename, const int order) const;
+  void writeDynamicCFile(const string &basename, int order) const;
   //! Writes dynamic model file when SparseDLL option is on
   void writeSparseDynamicMFile(const string &basename) const;
   //! Writes the dynamic model equations and its derivatives
@@ -134,11 +134,11 @@ private:
   //! Writes the Block reordred structure of the model in M output
   void writeModelEquationsOrdered_M(const string &basename) const;
   //! Writes the code of the Block reordred structure of the model in virtual machine bytecode
-  void writeModelEquationsCode_Block(const string &basename, const map_idx_t &map_idx, const bool linear_decomposition) const;
+  void writeModelEquationsCode_Block(const string &basename, const map_idx_t &map_idx, bool linear_decomposition) const;
   //! Writes the code of the model in virtual machine bytecode
   void writeModelEquationsCode(const string &basename, const map_idx_t &map_idx) const;
 
-  void writeSetAuxiliaryVariables(const string &basename, const bool julia) const;
+  void writeSetAuxiliaryVariables(const string &basename, bool julia) const;
   void writeAuxVarRecursiveDefinitions(ostream &output, ExprNodeOutputType output_type) const;
 
   //! Computes jacobian and prepares for equation normalization
@@ -153,7 +153,7 @@ private:
   //! Computes chain rule derivatives of the Jacobian w.r. to endogenous variables
   void computeChainRuleJacobian(blocks_derivatives_t &blocks_derivatives);
 
-  string reform(string name) const;
+  string reform(const string &name) const;
   map_idx_t map_idx;
 
   //! sorts the temporary terms in the blocks order
@@ -410,7 +410,7 @@ public:
 
   //! Adds informations for simulation in a binary file
   void Write_Inf_To_Bin_File_Block(const string &basename,
-                                   const int &num, int &u_count_int, bool &file_open, bool is_two_boundaries, const bool linear_decomposition) const;
+                                   int num, int &u_count_int, bool &file_open, bool is_two_boundaries, bool linear_decomposition) const;
   //! Writes dynamic model file
   void writeDynamicFile(const string &basename, bool block, bool linear_decomposition, bool bytecode, bool use_dll, const string &mexext, const filesystem::path &matlabroot, const filesystem::path &dynareroot, int order, bool julia) const;
   //! Writes file containing parameters derivatives
@@ -456,10 +456,10 @@ public:
   size_t dynamicOnlyEquationsNbr() const;
 
   //! Writes LaTeX file with the equations of the dynamic model
-  void writeLatexFile(const string &basename, const bool write_equation_tags) const;
+  void writeLatexFile(const string &basename, bool write_equation_tags) const;
 
   //! Writes LaTeX file with the equations of the dynamic model (for the original model)
-  void writeLatexOriginalFile(const string &basename, const bool write_equation_tags) const;
+  void writeLatexOriginalFile(const string &basename, bool write_equation_tags) const;
 
   int getDerivID(int symb_id, int lag) const noexcept(false) override;
   int getDynJacobianCol(int deriv_id) const noexcept(false) override;
@@ -587,164 +587,163 @@ public:
   unsigned int
   getNbBlocks() const override
   {
-    return (block_type_firstequation_size_mfs.size());
+    return block_type_firstequation_size_mfs.size();
   };
   //! Determine the simulation type of each block
   BlockSimulationType
   getBlockSimulationType(int block_number) const override
   {
-    return (get<0>(block_type_firstequation_size_mfs[block_number]));
+    return get<0>(block_type_firstequation_size_mfs[block_number]);
   };
   //! Return the first equation number of a block
   unsigned int
   getBlockFirstEquation(int block_number) const override
   {
-    return (get<1>(block_type_firstequation_size_mfs[block_number]));
+    return get<1>(block_type_firstequation_size_mfs[block_number]);
   };
   //! Return the size of the block block_number
   unsigned int
   getBlockSize(int block_number) const override
   {
-    return (get<2>(block_type_firstequation_size_mfs[block_number]));
+    return get<2>(block_type_firstequation_size_mfs[block_number]);
   };
   //! Return the number of exogenous variable in the block block_number
   unsigned int
   getBlockExoSize(int block_number) const override
   {
-    return (block_var_exo[block_number].first.size());
+    return block_var_exo[block_number].first.size();
   };
   //! Return the number of colums in the jacobian matrix for exogenous variable in the block block_number
   unsigned int
   getBlockExoColSize(int block_number) const override
   {
-    return (block_var_exo[block_number].second);
+    return block_var_exo[block_number].second;
   };
   //! Return the number of feedback variable of the block block_number
   unsigned int
   getBlockMfs(int block_number) const override
   {
-    return (get<3>(block_type_firstequation_size_mfs[block_number]));
+    return get<3>(block_type_firstequation_size_mfs[block_number]);
   };
   //! Return the maximum lag in a block
   unsigned int
   getBlockMaxLag(int block_number) const override
   {
-    return (block_lag_lead[block_number].first);
+    return block_lag_lead[block_number].first;
   };
   //! Return the maximum lead in a block
   unsigned int
   getBlockMaxLead(int block_number) const override
   {
-    return (block_lag_lead[block_number].second);
+    return block_lag_lead[block_number].second;
   };
   //! Return the type of equation (equation_number) belonging to the block block_number
   EquationType
   getBlockEquationType(int block_number, int equation_number) const override
   {
-    return (equation_type_and_normalized_equation[equation_reordered[get<1>(block_type_firstequation_size_mfs[block_number])+equation_number]].first);
+    return equation_type_and_normalized_equation[equation_reordered[get<1>(block_type_firstequation_size_mfs[block_number])+equation_number]].first;
   };
   //! Return true if the equation has been normalized
   bool
   isBlockEquationRenormalized(int block_number, int equation_number) const override
   {
-    return (equation_type_and_normalized_equation[equation_reordered[get<1>(block_type_firstequation_size_mfs[block_number])+equation_number]].first == E_EVALUATE_S);
+    return equation_type_and_normalized_equation[equation_reordered[get<1>(block_type_firstequation_size_mfs[block_number])+equation_number]].first == E_EVALUATE_S;
   };
   //! Return the expr_t of the equation equation_number belonging to the block block_number
   expr_t
   getBlockEquationExpr(int block_number, int equation_number) const override
   {
-    return (equations[equation_reordered[get<1>(block_type_firstequation_size_mfs[block_number])+equation_number]]);
+    return equations[equation_reordered[get<1>(block_type_firstequation_size_mfs[block_number])+equation_number]];
   };
   //! Return the expr_t of the renormalized equation equation_number belonging to the block block_number
   expr_t
   getBlockEquationRenormalizedExpr(int block_number, int equation_number) const override
   {
-    return (equation_type_and_normalized_equation[equation_reordered[get<1>(block_type_firstequation_size_mfs[block_number])+equation_number]].second);
+    return equation_type_and_normalized_equation[equation_reordered[get<1>(block_type_firstequation_size_mfs[block_number])+equation_number]].second;
   };
   //! Return the original number of equation equation_number belonging to the block block_number
   int
   getBlockEquationID(int block_number, int equation_number) const override
   {
-    return (equation_reordered[get<1>(block_type_firstequation_size_mfs[block_number])+equation_number]);
+    return equation_reordered[get<1>(block_type_firstequation_size_mfs[block_number])+equation_number];
   };
   //! Return the original number of variable variable_number belonging to the block block_number
   int
   getBlockVariableID(int block_number, int variable_number) const override
   {
-    return (variable_reordered[get<1>(block_type_firstequation_size_mfs[block_number])+variable_number]);
+    return variable_reordered[get<1>(block_type_firstequation_size_mfs[block_number])+variable_number];
   };
   //! Return the original number of the exogenous variable varexo_number belonging to the block block_number
   int
   getBlockVariableExoID(int block_number, int variable_number) const override
   {
-    auto it = exo_block[block_number].find(variable_number);
-    return (it->first);
+    return exo_block[block_number].find(variable_number)->first;
   };
   //! Return the position of equation_number in the block number belonging to the block block_number
   int
   getBlockInitialEquationID(int block_number, int equation_number) const override
   {
-    return (static_cast<int>(inv_equation_reordered[equation_number]) - static_cast<int>(get<1>(block_type_firstequation_size_mfs[block_number])));
+    return static_cast<int>(inv_equation_reordered[equation_number]) - static_cast<int>(get<1>(block_type_firstequation_size_mfs[block_number]));
   };
   //! Return the position of variable_number in the block number belonging to the block block_number
   int
   getBlockInitialVariableID(int block_number, int variable_number) const override
   {
-    return (static_cast<int>(inv_variable_reordered[variable_number]) - static_cast<int>(get<1>(block_type_firstequation_size_mfs[block_number])));
+    return static_cast<int>(inv_variable_reordered[variable_number]) - static_cast<int>(get<1>(block_type_firstequation_size_mfs[block_number]));
   };
   //! Return the block number containing the endogenous variable variable_number
   int
   getBlockVariableID(int variable_number) const
   {
-    return (get<0>(variable_block_lead_lag[variable_number]));
+    return get<0>(variable_block_lead_lag[variable_number]);
   };
   //! Return the position of the exogenous variable_number in the block number belonging to the block block_number
   int
   getBlockInitialExogenousID(int block_number, int variable_number) const override
   {
-    auto it = block_exo_index.find(block_number);
-    if (it != block_exo_index.end())
+    if (auto it = block_exo_index.find(block_number);
+        it != block_exo_index.end())
       {
-        auto it1 = it->second.find(variable_number);
-        if (it1 != it->second.end())
+        if (auto it1 = it->second.find(variable_number);
+            it1 != it->second.end())
           return it1->second;
         else
           return -1;
       }
     else
-      return (-1);
+      return -1;
   };
   //! Return the position of the deterministic exogenous variable_number in the block number belonging to the block block_number
   int
   getBlockInitialDetExogenousID(int block_number, int variable_number) const override
   {
-    auto it = block_det_exo_index.find(block_number);
-    if (it != block_det_exo_index.end())
+    if (auto it = block_det_exo_index.find(block_number);
+        it != block_det_exo_index.end())
       {
-        auto it1 = it->second.find(variable_number);
-        if (it1 != it->second.end())
+        if (auto it1 = it->second.find(variable_number);
+            it1 != it->second.end())
           return it1->second;
         else
           return -1;
       }
     else
-      return (-1);
+      return -1;
   };
   //! Return the position of the other endogenous variable_number in the block number belonging to the block block_number
   int
   getBlockInitialOtherEndogenousID(int block_number, int variable_number) const override
   {
-    auto it = block_other_endo_index.find(block_number);
-    if (it != block_other_endo_index.end())
+    if (auto it = block_other_endo_index.find(block_number);
+        it != block_other_endo_index.end())
       {
-        auto it1 = it->second.find(variable_number);
-        if (it1 != it->second.end())
+        if (auto it1 = it->second.find(variable_number);
+            it1 != it->second.end())
           return it1->second;
         else
           return -1;
       }
     else
-      return (-1);
+      return -1;
   };
   bool isModelLocalVariableUsed() const;
 
diff --git a/src/DynareMain.cc b/src/DynareMain.cc
index d4bc64083ef0a1530f32f5fb647277dcfdb05b37..149d7f273414f209616e2e02f5cc53a0b19fcb46 100644
--- a/src/DynareMain.cc
+++ b/src/DynareMain.cc
@@ -81,15 +81,15 @@ parse_options_line(istream &modfile)
   while (getline(modfile, first_nonempty_line))
     if (first_nonempty_line != "")
       {
-        if (regex_search(first_nonempty_line, matches, pat))
-          if (matches.size() > 1 && matches[1].matched)
-            {
-              regex pat2{R"(([^,\s]+))"};
-              string s{matches[1]};
-              for (sregex_iterator p(s.begin(), s.end(), pat2);
-                   p != sregex_iterator{}; ++p)
-                options.push_back((*p)[1]);
-            }
+        if (regex_search(first_nonempty_line, matches, pat)
+            && matches.size() > 1 && matches[1].matched)
+          {
+            regex pat2{R"(([^,\s]+))"};
+            string s{matches[1]};
+            for (sregex_iterator p(s.begin(), s.end(), pat2);
+                 p != sregex_iterator{}; ++p)
+              options.push_back((*p)[1]);
+          }
         break;
       }
 
@@ -272,8 +272,8 @@ main(int argc, char **argv)
               usage();
             }
 
-          auto equal_index = s.find('=');
-          if (equal_index != string::npos)
+          if (auto equal_index = s.find('=');
+              equal_index != string::npos)
             defines.emplace_back(s.substr(2, equal_index-2), s.substr(equal_index+1));
           else
             defines.emplace_back(s.substr(2), "1");
@@ -286,7 +286,7 @@ main(int argc, char **argv)
                    << "must not be separated from -I by whitespace." << endl;
               usage();
             }
-          paths.push_back(s.substr(2));
+          paths.emplace_back(s.substr(2));
         }
       else if (s.substr(0, 6) == "output")
         {
@@ -413,8 +413,8 @@ main(int argc, char **argv)
 
   // Construct basename (i.e. remove file extension if there is one)
   string basename = argv[1];
-  size_t pos = basename.find_last_of('.');
-  if (pos != string::npos)
+  if (size_t pos = basename.find_last_of('.');
+      pos != string::npos)
     basename.erase(pos);
 
   WarningConsolidation warnings(no_warn);
diff --git a/src/DynareMain1.cc b/src/DynareMain1.cc
index 621d178e128c05d9ff666a28138e923243d6548c..db061798832faedf1b20b8c5a77d5a580b08c85a 100644
--- a/src/DynareMain1.cc
+++ b/src/DynareMain1.cc
@@ -23,10 +23,6 @@
 
 #include "macro/Driver.hh"
 
-bool compareNewline (int i, int j) {
-  return i == '\n' && j == '\n';
-}
-
 void
 main1(const string &filename, const string &basename, istream &modfile, bool debug, bool save_macro, string &save_macro_file,
       bool no_line_macro_arg, bool no_empty_line_macro, const vector<pair<string, string>> &defines,
@@ -50,6 +46,7 @@ main1(const string &filename, const string &basename, istream &modfile, bool deb
       string str (macro_output.str());
       if (no_empty_line_macro)
         {
+          auto compareNewline = [](char i, char j) { return i == '\n' && j == '\n'; };
           str.erase(0, str.find_first_not_of('\n'));
           str.erase(unique(str.begin(), str.end(), compareNewline), str.end());
         }
diff --git a/src/ExprNode.cc b/src/ExprNode.cc
index c2dad5ce74b6f0d1d3e39f7436eeae72c47733c3..427d0a9e7c8e587ff4258a371776bea13b4201a7 100644
--- a/src/ExprNode.cc
+++ b/src/ExprNode.cc
@@ -217,7 +217,7 @@ void
 ExprNode::writeJsonExternalFunctionOutput(vector<string> &efout,
                                           const temporary_terms_t &temporary_terms,
                                           deriv_node_temp_terms_t &tef_terms,
-                                          const bool isdynamic) const
+                                          bool isdynamic) const
 {
   // Nothing to do
 }
@@ -237,8 +237,8 @@ ExprNode::createEndoLeadAuxiliaryVarForMyself(subst_table_t &subst_table, vector
   int n = maxEndoLead();
   assert(n >= 2);
 
-  subst_table_t::const_iterator it = subst_table.find(this);
-  if (it != subst_table.end())
+  if (auto it = subst_table.find(this);
+      it != subst_table.end())
     return const_cast<VariableNode *>(it->second);
 
   expr_t substexpr = decreaseLeadsLags(n-1);
@@ -249,12 +249,12 @@ ExprNode::createEndoLeadAuxiliaryVarForMyself(subst_table_t &subst_table, vector
   while (lag >= 0)
     {
       expr_t orig_expr = decreaseLeadsLags(lag);
-      if (it = subst_table.find(orig_expr); it == subst_table.end())
+      if (auto it = subst_table.find(orig_expr); it == subst_table.end())
         {
           int symb_id = datatree.symbol_table.addEndoLeadAuxiliaryVar(orig_expr->idx, substexpr);
           neweqs.push_back(dynamic_cast<BinaryOpNode *>(datatree.AddEqual(datatree.AddVariable(symb_id, 0), substexpr)));
           substexpr = datatree.AddVariable(symb_id, +1);
-          assert(dynamic_cast<VariableNode *>(substexpr) != nullptr);
+          assert(dynamic_cast<VariableNode *>(substexpr));
           subst_table[orig_expr] = dynamic_cast<VariableNode *>(substexpr);
         }
       else
@@ -272,8 +272,8 @@ ExprNode::createExoLeadAuxiliaryVarForMyself(subst_table_t &subst_table, vector<
   int n = maxExoLead();
   assert(n >= 1);
 
-  subst_table_t::const_iterator it = subst_table.find(this);
-  if (it != subst_table.end())
+  if (auto it = subst_table.find(this);
+      it != subst_table.end())
     return const_cast<VariableNode *>(it->second);
 
   expr_t substexpr = decreaseLeadsLags(n);
@@ -284,12 +284,12 @@ ExprNode::createExoLeadAuxiliaryVarForMyself(subst_table_t &subst_table, vector<
   while (lag >= 0)
     {
       expr_t orig_expr = decreaseLeadsLags(lag);
-      if (it = subst_table.find(orig_expr); it == subst_table.end())
+      if (auto it = subst_table.find(orig_expr); it == subst_table.end())
         {
           int symb_id = datatree.symbol_table.addExoLeadAuxiliaryVar(orig_expr->idx, substexpr);
           neweqs.push_back(dynamic_cast<BinaryOpNode *>(datatree.AddEqual(datatree.AddVariable(symb_id, 0), substexpr)));
           substexpr = datatree.AddVariable(symb_id, +1);
-          assert(dynamic_cast<VariableNode *>(substexpr) != nullptr);
+          assert(dynamic_cast<VariableNode *>(substexpr));
           subst_table[orig_expr] = dynamic_cast<VariableNode *>(substexpr);
         }
       else
@@ -365,13 +365,6 @@ ExprNode::fillErrorCorrectionRow(int eqn,
       // Now fill the matrices
       for (auto [var_id, lag, param_id, constant] : m.second)
         {
-          /*
-          if (lag != -1)
-            {
-              cerr << "ERROR in trend component model: variables should appear with a lag of 1 in error correction term" << endl;
-              exit(EXIT_FAILURE);
-            }
-          */
           int orig_vid = one_step_orig(var_id);
           int orig_lag = datatree.symbol_table.isAuxiliaryVariable(var_id) ? -datatree.symbol_table.getOrigLeadLagForDiffAuxVar(var_id) : lag;
           if (find(target_lhs.begin(), target_lhs.end(), orig_vid) == target_lhs.end())
@@ -467,7 +460,7 @@ void
 NumConstNode::writeJsonOutput(ostream &output,
                               const temporary_terms_t &temporary_terms,
                               const deriv_node_temp_terms_t &tef_terms,
-                              const bool isdynamic) const
+                              bool isdynamic) const
 {
   output << datatree.num_constants.get(id);
 }
@@ -481,7 +474,7 @@ NumConstNode::containsExternalFunction() const
 double
 NumConstNode::eval(const eval_context_t &eval_context) const noexcept(false)
 {
-  return (datatree.num_constants.getDouble(id));
+  return datatree.num_constants.getDouble(id);
 }
 
 void
@@ -956,7 +949,7 @@ void
 VariableNode::writeJsonOutput(ostream &output,
                               const temporary_terms_t &temporary_terms,
                               const deriv_node_temp_terms_t &tef_terms,
-                              const bool isdynamic) const
+                              bool isdynamic) const
 {
   if (temporary_terms.find(const_cast<VariableNode *>(this)) != temporary_terms.end())
     {
@@ -1418,11 +1411,11 @@ VariableNode::getChainRuleDerivative(int deriv_id, const map<int, expr_t> &recur
       else
         {
           //if there is in the equation a recursive variable we could use a chaine rule derivation
-          auto it = recursive_variables.find(datatree.getDerivID(symb_id, lag));
-          if (it != recursive_variables.end())
+          if (auto it = recursive_variables.find(datatree.getDerivID(symb_id, lag));
+              it != recursive_variables.end())
             {
-              map<int, expr_t>::const_iterator it2 = derivatives.find(deriv_id);
-              if (it2 != derivatives.end())
+              if (auto it2 = derivatives.find(deriv_id);
+                  it2 != derivatives.end())
                 return it2->second;
               else
                 {
@@ -1944,7 +1937,7 @@ VariableNode::containsEndogenous() const
 bool
 VariableNode::containsExogenous() const
 {
-  return (get_type() == SymbolType::exogenous || get_type() == SymbolType::exogenousDet);
+  return get_type() == SymbolType::exogenous || get_type() == SymbolType::exogenousDet;
 }
 
 expr_t
@@ -1992,7 +1985,7 @@ VariableNode::removeTrendLeadLag(const map<int, expr_t> &trend_symbols_map) cons
   if ((get_type() != SymbolType::trend && get_type() != SymbolType::logTrend) || lag == 0)
     return const_cast<VariableNode *>(this);
 
-  map<int, expr_t>::const_iterator it = trend_symbols_map.find(symb_id);
+  auto it = trend_symbols_map.find(symb_id);
   expr_t noTrendLeadLagNode = datatree.AddVariable(it->first);
   bool log_trend = get_type() == SymbolType::logTrend;
   expr_t trend = it->second;
@@ -2181,8 +2174,8 @@ UnaryOpNode::composeDerivatives(expr_t darg, int deriv_id)
         {
           if (datatree.getTypeByDerivID(deriv_id) == SymbolType::parameter)
             {
-              auto *varg = dynamic_cast<VariableNode *>(arg);
-              if (varg == nullptr)
+              auto varg = dynamic_cast<VariableNode *>(arg);
+              if (!varg)
                 {
                   cerr << "UnaryOpNode::composeDerivatives: STEADY_STATE() should only be used on "
                        << "standalone variables (like STEADY_STATE(y)) to be derivable w.r.t. parameters" << endl;
@@ -2202,8 +2195,8 @@ UnaryOpNode::composeDerivatives(expr_t darg, int deriv_id)
       assert(datatree.isDynamic());
       if (datatree.getTypeByDerivID(deriv_id) == SymbolType::parameter)
         {
-          auto *varg = dynamic_cast<VariableNode *>(arg);
-          assert(varg != nullptr);
+          auto varg = dynamic_cast<VariableNode *>(arg);
+          assert(varg);
           assert(datatree.symbol_table.getType(varg->symb_id) == SymbolType::endogenous);
           return datatree.AddSteadyStateParam2ndDeriv(arg, param1_symb_id, datatree.getSymbIDByDerivID(deriv_id));
         }
@@ -2387,8 +2380,8 @@ UnaryOpNode::computeTemporaryTerms(const pair<int, int> &derivOrder,
                                    bool is_matlab) const
 {
   expr_t this2 = const_cast<UnaryOpNode *>(this);
-  auto it = reference_count.find(this2);
-  if (it == reference_count.end())
+  if (auto it = reference_count.find(this2);
+      it == reference_count.end())
     {
       reference_count[this2] = { 1, derivOrder };
       arg->computeTemporaryTerms(derivOrder, temp_terms_map, reference_count, is_matlab);
@@ -2410,8 +2403,8 @@ UnaryOpNode::computeTemporaryTerms(map<expr_t, int> &reference_count,
                                    int equation) const
 {
   expr_t this2 = const_cast<UnaryOpNode *>(this);
-  auto it = reference_count.find(this2);
-  if (it == reference_count.end())
+  if (auto it = reference_count.find(this2);
+      it == reference_count.end())
     {
       reference_count[this2] = 1;
       first_occurence[this2] = { Curr_block, equation };
@@ -2537,7 +2530,7 @@ UnaryOpNode::writeJsonAST(ostream &output) const
     case UnaryOpcode::adl:
       output << R"(, "adl_param_name" : ")" << adl_param_name << R"(")"
              << R"(, "lags" : [)";
-      for (auto it = adl_lags.begin(); it != adl_lags.end(); it++)
+      for (auto it = adl_lags.begin(); it != adl_lags.end(); ++it)
         {
           if (it != adl_lags.begin())
             output << ", ";
@@ -2555,7 +2548,7 @@ void
 UnaryOpNode::writeJsonOutput(ostream &output,
                              const temporary_terms_t &temporary_terms,
                              const deriv_node_temp_terms_t &tef_terms,
-                              const bool isdynamic) const
+                              bool isdynamic) const
 {
   if (temporary_terms.find(const_cast<UnaryOpNode *>(this)) != temporary_terms.end())
     {
@@ -2636,7 +2629,7 @@ UnaryOpNode::writeJsonOutput(ostream &output,
       output << "adl(";
       arg->writeJsonOutput(output, temporary_terms, tef_terms);
       output << ", '" << adl_param_name << "', [";
-      for (auto it = adl_lags.begin(); it != adl_lags.end(); it++)
+      for (auto it = adl_lags.begin(); it != adl_lags.end(); ++it)
         {
           if (it != adl_lags.begin())
             output << ", ";
@@ -2651,8 +2644,8 @@ UnaryOpNode::writeJsonOutput(ostream &output,
       return;
     case UnaryOpcode::steadyStateParamDeriv:
       {
-        auto *varg = dynamic_cast<VariableNode *>(arg);
-        assert(varg != nullptr);
+        auto varg = dynamic_cast<VariableNode *>(arg);
+        assert(varg);
         assert(datatree.symbol_table.getType(varg->symb_id) == SymbolType::endogenous);
         assert(datatree.symbol_table.getType(param1_symb_id) == SymbolType::parameter);
         int tsid_endo = datatree.symbol_table.getTypeSpecificID(varg->symb_id);
@@ -2662,8 +2655,8 @@ UnaryOpNode::writeJsonOutput(ostream &output,
       return;
     case UnaryOpcode::steadyStateParam2ndDeriv:
       {
-        auto *varg = dynamic_cast<VariableNode *>(arg);
-        assert(varg != nullptr);
+        auto varg = dynamic_cast<VariableNode *>(arg);
+        assert(varg);
         assert(datatree.symbol_table.getType(varg->symb_id) == SymbolType::endogenous);
         assert(datatree.symbol_table.getType(param1_symb_id) == SymbolType::parameter);
         assert(datatree.symbol_table.getType(param2_symb_id) == SymbolType::parameter);
@@ -2854,8 +2847,8 @@ UnaryOpNode::writeOutput(ostream &output, ExprNodeOutputType output_type,
       return;
     case UnaryOpcode::steadyStateParamDeriv:
       {
-        auto *varg = dynamic_cast<VariableNode *>(arg);
-        assert(varg != nullptr);
+        auto varg = dynamic_cast<VariableNode *>(arg);
+        assert(varg);
         assert(datatree.symbol_table.getType(varg->symb_id) == SymbolType::endogenous);
         assert(datatree.symbol_table.getType(param1_symb_id) == SymbolType::parameter);
         int tsid_endo = datatree.symbol_table.getTypeSpecificID(varg->symb_id);
@@ -2866,8 +2859,8 @@ UnaryOpNode::writeOutput(ostream &output, ExprNodeOutputType output_type,
       return;
     case UnaryOpcode::steadyStateParam2ndDeriv:
       {
-        auto *varg = dynamic_cast<VariableNode *>(arg);
-        assert(varg != nullptr);
+        auto varg = dynamic_cast<VariableNode *>(arg);
+        assert(varg);
         assert(datatree.symbol_table.getType(varg->symb_id) == SymbolType::endogenous);
         assert(datatree.symbol_table.getType(param1_symb_id) == SymbolType::parameter);
         assert(datatree.symbol_table.getType(param2_symb_id) == SymbolType::parameter);
@@ -2945,7 +2938,7 @@ void
 UnaryOpNode::writeJsonExternalFunctionOutput(vector<string> &efout,
                                              const temporary_terms_t &temporary_terms,
                                              deriv_node_temp_terms_t &tef_terms,
-                                             const bool isdynamic) const
+                                             bool isdynamic) const
 {
   arg->writeJsonExternalFunctionOutput(efout, temporary_terms, tef_terms, isdynamic);
 }
@@ -2966,47 +2959,47 @@ UnaryOpNode::eval_opcode(UnaryOpcode op_code, double v) noexcept(false)
   switch (op_code)
     {
     case UnaryOpcode::uminus:
-      return (-v);
+      return -v;
     case UnaryOpcode::exp:
-      return (exp(v));
+      return exp(v);
     case UnaryOpcode::log:
-      return (log(v));
+      return log(v);
     case UnaryOpcode::log10:
-      return (log10(v));
+      return log10(v);
     case UnaryOpcode::cos:
-      return (cos(v));
+      return cos(v);
     case UnaryOpcode::sin:
-      return (sin(v));
+      return sin(v);
     case UnaryOpcode::tan:
-      return (tan(v));
+      return tan(v);
     case UnaryOpcode::acos:
-      return (acos(v));
+      return acos(v);
     case UnaryOpcode::asin:
-      return (asin(v));
+      return asin(v);
     case UnaryOpcode::atan:
-      return (atan(v));
+      return atan(v);
     case UnaryOpcode::cosh:
-      return (cosh(v));
+      return cosh(v);
     case UnaryOpcode::sinh:
-      return (sinh(v));
+      return sinh(v);
     case UnaryOpcode::tanh:
-      return (tanh(v));
+      return tanh(v);
     case UnaryOpcode::acosh:
-      return (acosh(v));
+      return acosh(v);
     case UnaryOpcode::asinh:
-      return (asinh(v));
+      return asinh(v);
     case UnaryOpcode::atanh:
-      return (atanh(v));
+      return atanh(v);
     case UnaryOpcode::sqrt:
-      return (sqrt(v));
+      return sqrt(v);
     case UnaryOpcode::cbrt:
-      return (cbrt(v));
+      return cbrt(v);
     case UnaryOpcode::abs:
-      return (abs(v));
+      return abs(v);
     case UnaryOpcode::sign:
       return (v > 0) ? 1 : ((v < 0) ? -1 : 0);
     case UnaryOpcode::steadyState:
-      return (v);
+      return v;
     case UnaryOpcode::steadyStateParamDeriv:
       cerr << "UnaryOpNode::eval_opcode: not implemented on UnaryOpcode::steadyStateParamDeriv" << endl;
       exit(EXIT_FAILURE);
@@ -3017,7 +3010,7 @@ UnaryOpNode::eval_opcode(UnaryOpcode op_code, double v) noexcept(false)
       cerr << "UnaryOpNode::eval_opcode: not implemented on UnaryOpcode::expectation" << endl;
       exit(EXIT_FAILURE);
     case UnaryOpcode::erf:
-      return (erf(v));
+      return erf(v);
     case UnaryOpcode::diff:
       cerr << "UnaryOpNode::eval_opcode: not implemented on UnaryOpcode::diff" << endl;
       exit(EXIT_FAILURE);
@@ -3372,8 +3365,7 @@ int
 UnaryOpNode::VarMaxLag(const set<expr_t> &lhs_lag_equiv) const
 {
   auto [lag_equiv_repr, index] = getLagEquivalenceClass();
-  auto it = lhs_lag_equiv.find(lag_equiv_repr);
-  if (it == lhs_lag_equiv.end())
+  if (lhs_lag_equiv.find(lag_equiv_repr) == lhs_lag_equiv.end())
     return 0;
   return arg->maxLag();
 }
@@ -3410,7 +3402,7 @@ UnaryOpNode::substituteAdl() const
   expr_t retval = nullptr;
   ostringstream inttostr;
 
-  for (auto it = adl_lags.begin(); it != adl_lags.end(); it++)
+  for (auto it = adl_lags.begin(); it != adl_lags.end(); ++it)
     if (it == adl_lags.begin())
       {
         inttostr << *it;
@@ -3515,8 +3507,8 @@ UnaryOpNode::substituteDiff(const lag_equivalence_table_t &nodes, subst_table_t
   if (op_code != UnaryOpcode::diff)
     return buildSimilarUnaryOpNode(argsubst, datatree);
 
-  auto sit = subst_table.find(this);
-  if (sit != subst_table.end())
+  if (auto sit = subst_table.find(this);
+      sit != subst_table.end())
     return const_cast<VariableNode *>(sit->second);
 
   auto [lag_equiv_repr, index] = getLagEquivalenceClass();
@@ -3546,11 +3538,11 @@ UnaryOpNode::substituteDiff(const lag_equivalence_table_t &nodes, subst_table_t
     {
       expr_t argsubst = dynamic_cast<UnaryOpNode *>(rit->second)->
           arg->substituteDiff(nodes, subst_table, neweqs);
-      auto *vn = dynamic_cast<VariableNode *>(argsubst);
+      auto vn = dynamic_cast<VariableNode *>(argsubst);
       int symb_id;
       if (rit == it->second.rbegin())
         {
-          if (vn != nullptr)
+          if (vn)
             symb_id = datatree.symbol_table.addDiffAuxiliaryVar(argsubst->idx, argsubst, vn->symb_id, vn->lag);
           else
             symb_id = datatree.symbol_table.addDiffAuxiliaryVar(argsubst->idx, argsubst);
@@ -3592,8 +3584,8 @@ UnaryOpNode::substituteDiff(const lag_equivalence_table_t &nodes, subst_table_t
 expr_t
 UnaryOpNode::substituteUnaryOpNodes(const lag_equivalence_table_t &nodes, subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs) const
 {
-  auto sit = subst_table.find(this);
-  if (sit != subst_table.end())
+  if (auto sit = subst_table.find(this);
+      sit != subst_table.end())
     return const_cast<VariableNode *>(sit->second);
 
   /* If the equivalence class of this node is not marked for substitution,
@@ -3692,8 +3684,8 @@ UnaryOpNode::substituteUnaryOpNodes(const lag_equivalence_table_t &nodes, subst_
           }
 
         int symb_id;
-        auto *vn = dynamic_cast<VariableNode *>(argsubst);
-        if (vn == nullptr)
+        auto vn = dynamic_cast<VariableNode *>(argsubst);
+        if (!vn)
           symb_id = datatree.symbol_table.addUnaryOpAuxiliaryVar(this->idx, dynamic_cast<UnaryOpNode *>(rit->second), unary_op);
         else
           symb_id = datatree.symbol_table.addUnaryOpAuxiliaryVar(this->idx, dynamic_cast<UnaryOpNode *>(rit->second), unary_op,
@@ -3707,8 +3699,7 @@ UnaryOpNode::substituteUnaryOpNodes(const lag_equivalence_table_t &nodes, subst_
     else
       subst_table[rit->second] = dynamic_cast<VariableNode *>(aux_var->decreaseLeadsLags(base_index - rit->first));
 
-  sit = subst_table.find(this);
-  return const_cast<VariableNode *>(sit->second);
+  return const_cast<VariableNode *>(subst_table.find(this)->second);
 }
 
 expr_t
@@ -3795,7 +3786,7 @@ UnaryOpNode::substituteExpectation(subst_table_t &subst_table, vector<BinaryOpNo
       expr_t newAuxE = datatree.AddVariable(symb_id, 0);
 
       if (partial_information_model && expectation_information_set == 0)
-        if (dynamic_cast<VariableNode *>(arg) == nullptr)
+        if (!dynamic_cast<VariableNode *>(arg))
           {
             cerr << "ERROR: In Partial Information models, EXPECTATION(0)(X) "
                  << "can only be used when X is a single variable." << endl;
@@ -3805,11 +3796,11 @@ UnaryOpNode::substituteExpectation(subst_table_t &subst_table, vector<BinaryOpNo
       //take care of any nested expectation operators by calling arg->substituteExpectation(.), then decreaseLeadsLags for this UnaryOpcode::expectation operator
       //arg(lag-period) (holds entire subtree of arg(lag-period)
       expr_t substexpr = (arg->substituteExpectation(subst_table, neweqs, partial_information_model))->decreaseLeadsLags(expectation_information_set);
-      assert(substexpr != nullptr);
+      assert(substexpr);
       neweqs.push_back(dynamic_cast<BinaryOpNode *>(datatree.AddEqual(newAuxE, substexpr))); //AUXE_period_arg.idx = arg(lag-period)
       newAuxE = datatree.AddVariable(symb_id, expectation_information_set);
 
-      assert(dynamic_cast<VariableNode *>(newAuxE) != nullptr);
+      assert(dynamic_cast<VariableNode *>(newAuxE));
       subst_table[this] = dynamic_cast<VariableNode *>(newAuxE);
       return newAuxE;
     }
@@ -4008,7 +3999,7 @@ BinaryOpNode::composeDerivatives(expr_t darg1, expr_t darg2)
         if (darg1 == datatree.Zero)
           return datatree.Zero;
         else
-          if (dynamic_cast<NumConstNode *>(arg2) != nullptr)
+          if (dynamic_cast<NumConstNode *>(arg2))
             {
               t11 = datatree.AddMinus(arg2, datatree.One);
               t12 = datatree.AddPower(arg1, t11);
@@ -4270,8 +4261,8 @@ BinaryOpNode::computeTemporaryTerms(const pair<int, int> &derivOrder,
                                     bool is_matlab) const
 {
   expr_t this2 = const_cast<BinaryOpNode *>(this);
-  auto it = reference_count.find(this2);
-  if (it == reference_count.end())
+  if (auto it = reference_count.find(this2);
+      it == reference_count.end())
     {
       // If this node has never been encountered, set its ref count to one,
       //  and travel through its children
@@ -4300,8 +4291,8 @@ BinaryOpNode::computeTemporaryTerms(map<expr_t, int> &reference_count,
                                     int equation) const
 {
   expr_t this2 = const_cast<BinaryOpNode *>(this);
-  auto it = reference_count.find(this2);
-  if (it == reference_count.end())
+  if (auto it = reference_count.find(this2);
+      it == reference_count.end())
     {
       reference_count[this2] = 1;
       first_occurence[this2] = { Curr_block, equation };
@@ -4326,15 +4317,15 @@ BinaryOpNode::eval_opcode(double v1, BinaryOpcode op_code, double v2, int derivO
   switch (op_code)
     {
     case BinaryOpcode::plus:
-      return (v1 + v2);
+      return v1 + v2;
     case BinaryOpcode::minus:
-      return (v1 - v2);
+      return v1 - v2;
     case BinaryOpcode::times:
-      return (v1 * v2);
+      return v1 * v2;
     case BinaryOpcode::divide:
-      return (v1 / v2);
+      return v1 / v2;
     case BinaryOpcode::power:
-      return (pow(v1, v2));
+      return pow(v1, v2);
     case BinaryOpcode::powerDeriv:
       if (fabs(v1) < near_zero && v2 > 0
           && derivOrder > v2
@@ -4358,17 +4349,17 @@ BinaryOpNode::eval_opcode(double v1, BinaryOpcode op_code, double v2, int derivO
       else
         return v1;
     case BinaryOpcode::less:
-      return (v1 < v2);
+      return v1 < v2;
     case BinaryOpcode::greater:
-      return (v1 > v2);
+      return v1 > v2;
     case BinaryOpcode::lessEqual:
-      return (v1 <= v2);
+      return v1 <= v2;
     case BinaryOpcode::greaterEqual:
-      return (v1 >= v2);
+      return v1 >= v2;
     case BinaryOpcode::equalEqual:
-      return (v1 == v2);
+      return v1 == v2;
     case BinaryOpcode::different:
-      return (v1 != v2);
+      return v1 != v2;
     case BinaryOpcode::equal:
       throw EvalException();
     }
@@ -4501,7 +4492,7 @@ void
 BinaryOpNode::writeJsonOutput(ostream &output,
                               const temporary_terms_t &temporary_terms,
                               const deriv_node_temp_terms_t &tef_terms,
-                              const bool isdynamic) const
+                              bool isdynamic) const
 {
   // If current node is a temporary term
   if (temporary_terms.find(const_cast<BinaryOpNode *>(this)) != temporary_terms.end())
@@ -4546,9 +4537,9 @@ BinaryOpNode::writeJsonOutput(ostream &output,
 
   // If left argument has a lower precedence, or if current and left argument are both power operators,
   // add parenthesis around left argument
-  if (auto *barg1 = dynamic_cast<BinaryOpNode *>(arg1);
+  if (auto barg1 = dynamic_cast<BinaryOpNode *>(arg1);
       arg1->precedenceJson(temporary_terms) < prec
-      || (op_code == BinaryOpcode::power && barg1 != nullptr && barg1->op_code == BinaryOpcode::power))
+      || (op_code == BinaryOpcode::power && barg1 && barg1->op_code == BinaryOpcode::power))
     {
       output << "(";
       close_parenthesis = true;
@@ -4610,9 +4601,9 @@ BinaryOpNode::writeJsonOutput(ostream &output,
      - it is a power operator and current operator is also a power operator
      - it is a minus operator with same precedence than current operator
      - it is a divide operator with same precedence than current operator */
-  auto *barg2 = dynamic_cast<BinaryOpNode *>(arg2);
+  auto barg2 = dynamic_cast<BinaryOpNode *>(arg2);
   if (int arg2_prec = arg2->precedenceJson(temporary_terms); arg2_prec < prec
-      || (op_code == BinaryOpcode::power && barg2 != nullptr && barg2->op_code == BinaryOpcode::power)
+      || (op_code == BinaryOpcode::power && barg2 && barg2->op_code == BinaryOpcode::power)
       || (op_code == BinaryOpcode::minus && arg2_prec == prec)
       || (op_code == BinaryOpcode::divide && arg2_prec == prec))
     {
@@ -4688,7 +4679,7 @@ BinaryOpNode::writeOutput(ostream &output, ExprNodeOutputType output_type,
   else
     {
       // If left argument has a lower precedence, or if current and left argument are both power operators, add parenthesis around left argument
-      auto *barg1 = dynamic_cast<BinaryOpNode *>(arg1);
+      auto barg1 = dynamic_cast<BinaryOpNode *>(arg1);
       if (arg1->precedence(output_type, temporary_terms) < prec
           || (op_code == BinaryOpcode::power && barg1 != nullptr && barg1->op_code == BinaryOpcode::power))
         {
@@ -4778,9 +4769,9 @@ BinaryOpNode::writeOutput(ostream &output, ExprNodeOutputType output_type,
          - it is a power operator and current operator is also a power operator
          - it is a minus operator with same precedence than current operator
          - it is a divide operator with same precedence than current operator */
-      auto *barg2 = dynamic_cast<BinaryOpNode *>(arg2);
+      auto barg2 = dynamic_cast<BinaryOpNode *>(arg2);
       if (int arg2_prec = arg2->precedence(output_type, temporary_terms); arg2_prec < prec
-          || (op_code == BinaryOpcode::power && barg2 != nullptr && barg2->op_code == BinaryOpcode::power && !isLatexOutput(output_type))
+          || (op_code == BinaryOpcode::power && barg2 && barg2->op_code == BinaryOpcode::power && !isLatexOutput(output_type))
           || (op_code == BinaryOpcode::minus && arg2_prec == prec)
           || (op_code == BinaryOpcode::divide && arg2_prec == prec && !isLatexOutput(output_type)))
         {
@@ -4813,7 +4804,7 @@ void
 BinaryOpNode::writeJsonExternalFunctionOutput(vector<string> &efout,
                                               const temporary_terms_t &temporary_terms,
                                               deriv_node_temp_terms_t &tef_terms,
-                                              const bool isdynamic) const
+                                              bool isdynamic) const
 {
   arg1->writeJsonExternalFunctionOutput(efout, temporary_terms, tef_terms, isdynamic);
   arg2->writeJsonExternalFunctionOutput(efout, temporary_terms, tef_terms, isdynamic);
@@ -5522,19 +5513,19 @@ BinaryOpNode::isVariableNodeEqualTo(SymbolType type_arg, int variable_id, int la
 bool
 BinaryOpNode::containsPacExpectation(const string &pac_model_name) const
 {
-  return (arg1->containsPacExpectation(pac_model_name) || arg2->containsPacExpectation(pac_model_name));
+  return arg1->containsPacExpectation(pac_model_name) || arg2->containsPacExpectation(pac_model_name);
 }
 
 bool
 BinaryOpNode::containsEndogenous() const
 {
-  return (arg1->containsEndogenous() || arg2->containsEndogenous());
+  return arg1->containsEndogenous() || arg2->containsEndogenous();
 }
 
 bool
 BinaryOpNode::containsExogenous() const
 {
-  return (arg1->containsExogenous() || arg2->containsExogenous());
+  return arg1->containsExogenous() || arg2->containsExogenous();
 }
 
 expr_t
@@ -5596,19 +5587,15 @@ BinaryOpNode::findTargetVariableHelper(const expr_t arg1, const expr_t arg2,
 
   set<pair<int, int>> endogs;
   arg2->collectDynamicVariables(SymbolType::endogenous, endogs);
-  if (endogs.size() == 2)
+  if (auto testarg2 = dynamic_cast<BinaryOpNode *>(arg2);
+      endogs.size() == 2 && testarg2 && testarg2->op_code == BinaryOpcode::minus
+      && dynamic_cast<VariableNode *>(testarg2->arg1)
+      && dynamic_cast<VariableNode *>(testarg2->arg2))
     {
-      auto *testarg2 = dynamic_cast<BinaryOpNode *>(arg2);
-      if (testarg2 != nullptr && testarg2->op_code == BinaryOpcode::minus)
-        {
-          auto *test_arg1 = dynamic_cast<VariableNode *>(testarg2->arg1);
-          auto *test_arg2 = dynamic_cast<VariableNode *>(testarg2->arg2);
-          if (test_arg1 != nullptr && test_arg2 != nullptr )
-            if (findTargetVariableHelper1(lhs_symb_id, endogs.begin()->first))
-              return endogs.rbegin()->first;
-            else if (findTargetVariableHelper1(lhs_symb_id, endogs.rbegin()->first))
-              return endogs.begin()->first;
-        }
+      if (findTargetVariableHelper1(lhs_symb_id, endogs.begin()->first))
+        return endogs.rbegin()->first;
+      else if (findTargetVariableHelper1(lhs_symb_id, endogs.rbegin()->first))
+        return endogs.begin()->first;
     }
   return -1;
 }
@@ -5639,12 +5626,12 @@ BinaryOpNode::getPacEC(BinaryOpNode *bopn, int lhs_symb_id, int lhs_orig_symb_id
     {
       optim_part = bopn->arg2;
       auto vn = dynamic_cast<VariableNode *>(bopn->arg1);
-      if (vn == nullptr || datatree.symbol_table.getType(vn->symb_id) != SymbolType::parameter)
+      if (!vn || datatree.symbol_table.getType(vn->symb_id) != SymbolType::parameter)
         {
           optim_part = bopn->arg1;
           vn = dynamic_cast<VariableNode *>(bopn->arg2);
         }
-      if (vn == nullptr || datatree.symbol_table.getType(vn->symb_id) != SymbolType::parameter)
+      if (!vn || datatree.symbol_table.getType(vn->symb_id) != SymbolType::parameter)
         return ec_params_and_vars;
       optim_param_symb_id = vn->symb_id;
     }
@@ -5692,8 +5679,8 @@ BinaryOpNode::getPacAREC(int lhs_symb_id, int lhs_orig_symb_id,
 {
   vector<pair<expr_t, int>> terms;
   decomposeAdditiveTerms(terms, 1);
-  for (auto it = terms.begin(); it != terms.end(); it++)
-    if (auto bopn = dynamic_cast<BinaryOpNode *>(it->first); bopn != nullptr)
+  for (auto it = terms.begin(); it != terms.end(); ++it)
+    if (auto bopn = dynamic_cast<BinaryOpNode *>(it->first); bopn)
       {
         ec_params_and_vars = getPacEC(bopn, lhs_symb_id, lhs_orig_symb_id);
         if (ec_params_and_vars.first >= 0)
@@ -5740,15 +5727,14 @@ BinaryOpNode::getPacAREC(int lhs_symb_id, int lhs_orig_symb_id,
         {
           if (pid == -1)
             pid = pidtmp;
-          else
-            if (pidtmp >= 0)
-              {
-                cerr << "unexpected parameter found in PAC equation" << endl;
-                exit(EXIT_FAILURE);
-              }
-
-          int vidorig = datatree.symbol_table.getUltimateOrigSymbID(vid);
-          if (vidorig == lhs_symb_id || vidorig == lhs_orig_symb_id)
+          else if (pidtmp >= 0)
+            {
+              cerr << "unexpected parameter found in PAC equation" << endl;
+              exit(EXIT_FAILURE);
+            }
+
+          if (int vidorig = datatree.symbol_table.getUltimateOrigSymbID(vid);
+              vidorig == lhs_symb_id || vidorig == lhs_orig_symb_id)
             {
               // This is an autoregressive term
               if (constant != 1 || pid == -1)
@@ -5771,8 +5757,8 @@ BinaryOpNode::isParamTimesEndogExpr() const
   if (op_code == BinaryOpcode::times)
     {
       set<int> params;
-      auto *test_arg1 = dynamic_cast<VariableNode *>(arg1);
-      auto *test_arg2 = dynamic_cast<VariableNode *>(arg2);
+      auto test_arg1 = dynamic_cast<VariableNode *>(arg1);
+      auto test_arg2 = dynamic_cast<VariableNode *>(arg2);
       if (test_arg1)
         arg1->collectVariables(SymbolType::parameter, params);
       else if (test_arg2)
@@ -5812,7 +5798,7 @@ BinaryOpNode::getPacNonOptimizingPartHelper(BinaryOpNode *bopn, int optim_share)
 {
   set<int> params;
   bopn->collectVariables(SymbolType::parameter, params);
-  if (params.size() == 1 && *(params.begin()) == optim_share)
+  if (params.size() == 1 && *params.begin() == optim_share)
     return true;
   return false;
 }
@@ -5822,16 +5808,14 @@ BinaryOpNode::getPacNonOptimizingPart(BinaryOpNode *bopn, int optim_share) const
 {
   auto a1 = dynamic_cast<BinaryOpNode *>(bopn->arg1);
   auto a2 = dynamic_cast<BinaryOpNode *>(bopn->arg2);
-  if (a1 == nullptr && a2 == nullptr)
+  if (!a1 && !a2)
     return nullptr;
 
-  if (a1 != nullptr)
-    if (getPacNonOptimizingPartHelper(a1, optim_share))
-      return bopn->arg2;
+  if (a1 && getPacNonOptimizingPartHelper(a1, optim_share))
+    return bopn->arg2;
 
-  if (a2 != nullptr)
-    if (getPacNonOptimizingPartHelper(a2, optim_share))
-      return bopn->arg1;
+  if (a2 && getPacNonOptimizingPartHelper(a2, optim_share))
+    return bopn->arg1;
 
   return nullptr;
 }
@@ -5869,7 +5853,7 @@ BinaryOpNode::getPacOptimizingShareAndExprNodes(int lhs_symb_id, int lhs_orig_sy
   vector<pair<expr_t, int>> terms;
   decomposeAdditiveTerms(terms, 1);
   for (auto & it : terms)
-    if (dynamic_cast<PacExpectationNode *>(it.first) != nullptr)
+    if (dynamic_cast<PacExpectationNode *>(it.first))
       // if the pac_expectation operator is additive in the expression
       // there are no optimizing shares
       return {-1, nullptr, nullptr, nullptr};
@@ -5878,36 +5862,35 @@ BinaryOpNode::getPacOptimizingShareAndExprNodes(int lhs_symb_id, int lhs_orig_sy
   expr_t optim_part, non_optim_part, additive_part;
   optim_part = non_optim_part = additive_part = nullptr;
 
-  for (auto it = terms.begin(); it != terms.end(); it++)
-    if (auto bopn = dynamic_cast<BinaryOpNode *>(it->first); bopn != nullptr)
+  for (auto it = terms.begin(); it != terms.end(); ++it)
+    if (auto bopn = dynamic_cast<BinaryOpNode *>(it->first); bopn)
       {
         tie(optim_share, optim_part) =
           getPacOptimizingShareAndExprNodesHelper(bopn, lhs_symb_id, lhs_orig_symb_id);
-        if (optim_share >= 0 && optim_part != nullptr)
+        if (optim_share >= 0 && optim_part)
           {
             terms.erase(it);
             break;
           }
       }
 
-  if (optim_part == nullptr)
+  if (!optim_part)
     return {-1, nullptr, nullptr, nullptr};
 
-  for (auto it = terms.begin(); it != terms.end(); it++)
-    if (auto bopn = dynamic_cast<BinaryOpNode *>(it->first); bopn != nullptr)
+  for (auto it = terms.begin(); it != terms.end(); ++it)
+    if (auto bopn = dynamic_cast<BinaryOpNode *>(it->first); bopn)
       {
         non_optim_part = getPacNonOptimizingPart(bopn, optim_share);
-        if (non_optim_part != nullptr)
+        if (non_optim_part)
           {
             terms.erase(it);
             break;
           }
       }
 
-  if (non_optim_part == nullptr)
+  if (!non_optim_part)
     return {-1, nullptr, nullptr, nullptr};
-
-  if (non_optim_part != nullptr)
+  else
     {
       additive_part = datatree.Zero;
       for (auto it : terms)
@@ -6208,8 +6191,8 @@ TrinaryOpNode::computeTemporaryTerms(const pair<int, int> &derivOrder,
                                      bool is_matlab) const
 {
   expr_t this2 = const_cast<TrinaryOpNode *>(this);
-  auto it = reference_count.find(this2);
-  if (it == reference_count.end())
+  if (auto it = reference_count.find(this2);
+      it == reference_count.end())
     {
       // If this node has never been encountered, set its ref count to one,
       //  and travel through its children
@@ -6237,8 +6220,8 @@ TrinaryOpNode::computeTemporaryTerms(map<expr_t, int> &reference_count,
                                      int equation) const
 {
   expr_t this2 = const_cast<TrinaryOpNode *>(this);
-  auto it = reference_count.find(this2);
-  if (it == reference_count.end())
+  if (auto it = reference_count.find(this2);
+      it == reference_count.end())
     {
       reference_count[this2] = 1;
       first_occurence[this2] = { Curr_block, equation };
@@ -6359,7 +6342,7 @@ void
 TrinaryOpNode::writeJsonOutput(ostream &output,
                                const temporary_terms_t &temporary_terms,
                                const deriv_node_temp_terms_t &tef_terms,
-                               const bool isdynamic) const
+                               bool isdynamic) const
 {
   // If current node is a temporary term
   if (temporary_terms.find(const_cast<TrinaryOpNode *>(this)) != temporary_terms.end())
@@ -6463,7 +6446,7 @@ void
 TrinaryOpNode::writeJsonExternalFunctionOutput(vector<string> &efout,
                                                const temporary_terms_t &temporary_terms,
                                                deriv_node_temp_terms_t &tef_terms,
-                                               const bool isdynamic) const
+                                               bool isdynamic) const
 {
   arg1->writeJsonExternalFunctionOutput(efout, temporary_terms, tef_terms, isdynamic);
   arg2->writeJsonExternalFunctionOutput(efout, temporary_terms, tef_terms, isdynamic);
@@ -7234,11 +7217,9 @@ int
 AbstractExternalFunctionNode::findTargetVariable(int lhs_symb_id) const
 {
   for (auto argument : arguments)
-    {
-      int retval = argument->findTargetVariable(lhs_symb_id);
-      if (retval >= 0)
-        return retval;
-    }
+    if (int retval = argument->findTargetVariable(lhs_symb_id);
+        retval >= 0)
+      return retval;
   return -1;
 }
 
@@ -7299,8 +7280,8 @@ AbstractExternalFunctionNode::alreadyWrittenAsTefTerm(int the_symb_id, const der
 int
 AbstractExternalFunctionNode::getIndxInTefTerms(int the_symb_id, const deriv_node_temp_terms_t &tef_terms) const noexcept(false)
 {
-  auto it = tef_terms.find({ the_symb_id, arguments });
-  if (it != tef_terms.end())
+  if (auto it = tef_terms.find({ the_symb_id, arguments });
+      it != tef_terms.end())
     return it->second;
   throw UnknownFunctionNameAndArgs();
 }
@@ -7323,14 +7304,12 @@ AbstractExternalFunctionNode::computeTemporaryTerms(const pair<int, int> &derivO
      previous level. */
 
   for (auto &tt : temp_terms_map)
-    {
-      auto it = find_if(tt.second.cbegin(), tt.second.cend(), sameTefTermPredicate());
-      if (it != tt.second.cend())
-        {
-          tt.second.insert(const_cast<AbstractExternalFunctionNode *>(this));
-          return;
-        }
-    }
+    if (auto it = find_if(tt.second.cbegin(), tt.second.cend(), sameTefTermPredicate());
+        it != tt.second.cend())
+      {
+        tt.second.insert(const_cast<AbstractExternalFunctionNode *>(this));
+        return;
+      }
 
   temp_terms_map[derivOrder].insert(const_cast<AbstractExternalFunctionNode *>(this));
 }
@@ -7457,8 +7436,7 @@ AbstractExternalFunctionNode::writeExternalFunctionArguments(ostream &output, Ex
                                                              const temporary_terms_idxs_t &temporary_terms_idxs,
                                                              const deriv_node_temp_terms_t &tef_terms) const
 {
-  for (auto it = arguments.begin();
-       it != arguments.end(); it++)
+  for (auto it = arguments.begin(); it != arguments.end(); ++it)
     {
       if (it != arguments.begin())
         output << ",";
@@ -7472,7 +7450,7 @@ AbstractExternalFunctionNode::writeJsonASTExternalFunctionArguments(ostream &out
 {
   int i = 0;
   output << "{";
-  for (auto it = arguments.begin(); it != arguments.end(); it++, i++)
+  for (auto it = arguments.begin(); it != arguments.end(); ++it, i++)
     {
       if (it != arguments.begin())
         output << ",";
@@ -7487,10 +7465,9 @@ void
 AbstractExternalFunctionNode::writeJsonExternalFunctionArguments(ostream &output,
                                                                  const temporary_terms_t &temporary_terms,
                                                                  const deriv_node_temp_terms_t &tef_terms,
-                                                                 const bool isdynamic) const
+                                                                 bool isdynamic) const
 {
-  for (auto it = arguments.begin();
-       it != arguments.end(); it++)
+  for (auto it = arguments.begin(); it != arguments.end(); ++it)
     {
       if (it != arguments.begin())
         output << ",";
@@ -7563,8 +7540,8 @@ ExternalFunctionNode::composeDerivatives(const vector<expr_t> &dargs)
                                        datatree.AddFirstDerivExternalFunction(symb_id, arguments, i+1)));
 
   expr_t theDeriv = datatree.Zero;
-  for (vector<expr_t>::const_iterator it = dNodes.begin(); it != dNodes.end(); it++)
-    theDeriv = datatree.AddPlus(theDeriv, *it);
+  for (auto & dNode : dNodes)
+    theDeriv = datatree.AddPlus(theDeriv, dNode);
   return theDeriv;
 }
 
@@ -7680,7 +7657,7 @@ void
 ExternalFunctionNode::writeJsonOutput(ostream &output,
                                       const temporary_terms_t &temporary_terms,
                                       const deriv_node_temp_terms_t &tef_terms,
-                                      const bool isdynamic) const
+                                      bool isdynamic) const
 {
   if (temporary_terms.find(const_cast<ExternalFunctionNode *>(this)) != temporary_terms.end())
     {
@@ -7801,7 +7778,7 @@ void
 ExternalFunctionNode::writeJsonExternalFunctionOutput(vector<string> &efout,
                                                       const temporary_terms_t &temporary_terms,
                                                       deriv_node_temp_terms_t &tef_terms,
-                                                      const bool isdynamic) const
+                                                      bool isdynamic) const
 {
   int first_deriv_symb_id = datatree.external_functions_table.getFirstDerivSymbID(symb_id);
   assert(first_deriv_symb_id != ExternalFunctionsTable::IDSetButNoNameProvided);
@@ -7906,8 +7883,8 @@ FirstDerivExternalFunctionNode::composeDerivatives(const vector<expr_t> &dargs)
     dNodes.push_back(datatree.AddTimes(dargs.at(i),
                                        datatree.AddSecondDerivExternalFunction(symb_id, arguments, inputIndex, i+1)));
   expr_t theDeriv = datatree.Zero;
-  for (vector<expr_t>::const_iterator it = dNodes.begin(); it != dNodes.end(); it++)
-    theDeriv = datatree.AddPlus(theDeriv, *it);
+  for (auto & dNode : dNodes)
+    theDeriv = datatree.AddPlus(theDeriv, dNode);
   return theDeriv;
 }
 
@@ -7924,7 +7901,7 @@ void
 FirstDerivExternalFunctionNode::writeJsonOutput(ostream &output,
                                                 const temporary_terms_t &temporary_terms,
                                                 const deriv_node_temp_terms_t &tef_terms,
-                                                const bool isdynamic) const
+                                                bool isdynamic) const
 {
   // If current node is a temporary term
   if (temporary_terms.find(const_cast<FirstDerivExternalFunctionNode *>(this)) != temporary_terms.end())
@@ -8131,7 +8108,7 @@ void
 FirstDerivExternalFunctionNode::writeJsonExternalFunctionOutput(vector<string> &efout,
                                                                 const temporary_terms_t &temporary_terms,
                                                                 deriv_node_temp_terms_t &tef_terms,
-                                                                const bool isdynamic) const
+                                                                bool isdynamic) const
 {
   int first_deriv_symb_id = datatree.external_functions_table.getFirstDerivSymbID(symb_id);
   assert(first_deriv_symb_id != ExternalFunctionsTable::IDSetButNoNameProvided);
@@ -8255,12 +8232,12 @@ FirstDerivExternalFunctionNode::sameTefTermPredicate() const
   if (first_deriv_symb_id == symb_id)
     return [this](expr_t e) {
       auto e2 = dynamic_cast<ExternalFunctionNode *>(e);
-      return (e2 != nullptr && e2->symb_id == symb_id);
+      return (e2 && e2->symb_id == symb_id);
     };
   else
     return [this](expr_t e) {
       auto e2 = dynamic_cast<FirstDerivExternalFunctionNode *>(e);
-      return (e2 != nullptr && e2->symb_id == symb_id);
+      return (e2 && e2->symb_id == symb_id);
     };
 }
 
@@ -8311,7 +8288,7 @@ void
 SecondDerivExternalFunctionNode::writeJsonOutput(ostream &output,
                                                  const temporary_terms_t &temporary_terms,
                                                  const deriv_node_temp_terms_t &tef_terms,
-                                                 const bool isdynamic) const
+                                                 bool isdynamic) const
 {
   // If current node is a temporary term
   if (temporary_terms.find(const_cast<SecondDerivExternalFunctionNode *>(this)) != temporary_terms.end())
@@ -8497,7 +8474,7 @@ void
 SecondDerivExternalFunctionNode::writeJsonExternalFunctionOutput(vector<string> &efout,
                                                                  const temporary_terms_t &temporary_terms,
                                                                  deriv_node_temp_terms_t &tef_terms,
-                                                                 const bool isdynamic) const
+                                                                 bool isdynamic) const
 {
   int second_deriv_symb_id = datatree.external_functions_table.getSecondDerivSymbID(symb_id);
   assert(second_deriv_symb_id != ExternalFunctionsTable::IDSetButNoNameProvided);
@@ -8597,12 +8574,12 @@ SecondDerivExternalFunctionNode::sameTefTermPredicate() const
   if (second_deriv_symb_id == symb_id)
     return [this](expr_t e) {
       auto e2 = dynamic_cast<ExternalFunctionNode *>(e);
-      return (e2 != nullptr && e2->symb_id == symb_id);
+      return (e2 && e2->symb_id == symb_id);
     };
   else
     return [this](expr_t e) {
       auto e2 = dynamic_cast<SecondDerivExternalFunctionNode *>(e);
-      return (e2 != nullptr && e2->symb_id == symb_id);
+      return (e2 && e2->symb_id == symb_id);
     };
 }
 
@@ -9053,7 +9030,7 @@ void
 VarExpectationNode::writeJsonOutput(ostream &output,
                                     const temporary_terms_t &temporary_terms,
                                     const deriv_node_temp_terms_t &tef_terms,
-                                    const bool isdynamic) const
+                                    bool isdynamic) const
 {
   output << "var_expectation("
          << "model_name = " << model_name
@@ -9456,7 +9433,7 @@ void
 PacExpectationNode::writeJsonOutput(ostream &output,
                                     const temporary_terms_t &temporary_terms,
                                     const deriv_node_temp_terms_t &tef_terms,
-                                    const bool isdynamic) const
+                                    bool isdynamic) const
 {
   output << "pac_expectation("
          << "model_name = " << model_name
diff --git a/src/ExprNode.hh b/src/ExprNode.hh
index f74bd1d1df8542791e6f0663aa16d671c6cf7a97..771cedda99855faf5b8847b571cfe48665257a7b 100644
--- a/src/ExprNode.hh
+++ b/src/ExprNode.hh
@@ -152,15 +152,37 @@ isLatexOutput(ExprNodeOutputType output_type)
 
 /* Equal to 1 for Matlab langage or Julia, or to 0 for C language. Not defined for LaTeX.
    In Matlab and Julia, array indexes begin at 1, while they begin at 0 in C */
-#define ARRAY_SUBSCRIPT_OFFSET(output_type) (static_cast<int>(isMatlabOutput(output_type) || isJuliaOutput(output_type)))
+inline int
+ARRAY_SUBSCRIPT_OFFSET(ExprNodeOutputType output_type)
+{
+  return static_cast<int>(isMatlabOutput(output_type) || isJuliaOutput(output_type));
+}
 
 // Left and right array subscript delimiters: '(' and ')' for Matlab, '[' and ']' for C
-#define LEFT_ARRAY_SUBSCRIPT(output_type) (isMatlabOutput(output_type) ? '(' : '[')
-#define RIGHT_ARRAY_SUBSCRIPT(output_type) (isMatlabOutput(output_type) ? ')' : ']')
+inline char
+LEFT_ARRAY_SUBSCRIPT(ExprNodeOutputType output_type)
+{
+  return isMatlabOutput(output_type) ? '(' : '[';
+}
+
+inline char
+RIGHT_ARRAY_SUBSCRIPT(ExprNodeOutputType output_type)
+{
+  return isMatlabOutput(output_type) ? ')' : ']';
+}
 
 // Left and right parentheses
-#define LEFT_PAR(output_type) (isLatexOutput(output_type) ? "\\left(" : "(")
-#define RIGHT_PAR(output_type) (isLatexOutput(output_type) ? "\\right)" : ")")
+inline string
+LEFT_PAR(ExprNodeOutputType output_type)
+{
+  return isLatexOutput(output_type) ? "\\left(" : "(";
+}
+
+inline string
+RIGHT_PAR(ExprNodeOutputType output_type)
+{
+  return isLatexOutput(output_type) ? "\\right)" : ")";
+}
 
 //! Base class for expression nodes
 class ExprNode
@@ -307,7 +329,7 @@ class ExprNode
       void writeOutput(ostream &output, ExprNodeOutputType output_type, const temporary_terms_t &temporary_terms, const temporary_terms_idxs_t &temporary_terms_idxs) const;
 
       //! Writes output of node in JSON syntax
-      virtual void writeJsonOutput(ostream &output, const temporary_terms_t &temporary_terms, const deriv_node_temp_terms_t &tef_terms, const bool isdynamic = true) const = 0;
+      virtual void writeJsonOutput(ostream &output, const temporary_terms_t &temporary_terms, const deriv_node_temp_terms_t &tef_terms, bool isdynamic = true) const = 0;
 
       //! Writes the Abstract Syntax Tree in JSON
       virtual void writeJsonAST(ostream &output) const = 0;
@@ -325,7 +347,7 @@ class ExprNode
       virtual void writeJsonExternalFunctionOutput(vector<string> &efout,
                                                    const temporary_terms_t &temporary_terms,
                                                    deriv_node_temp_terms_t &tef_terms,
-                                                   const bool isdynamic = true) const;
+                                                   bool isdynamic = true) const;
 
       virtual void compileExternalFunctionOutput(ostream &CompileCode, unsigned int &instruction_number,
                                                  bool lhs_rhs, const temporary_terms_t &temporary_terms,
@@ -711,7 +733,7 @@ public:
   void prepareForDerivation() override;
   void writeOutput(ostream &output, ExprNodeOutputType output_type, const temporary_terms_t &temporary_terms, const temporary_terms_idxs_t &temporary_terms_idxs, const deriv_node_temp_terms_t &tef_terms) const override;
   void writeJsonAST(ostream &output) const override;
-  void writeJsonOutput(ostream &output, const temporary_terms_t &temporary_terms, const deriv_node_temp_terms_t &tef_terms, const bool isdynamic) const override;
+  void writeJsonOutput(ostream &output, const temporary_terms_t &temporary_terms, const deriv_node_temp_terms_t &tef_terms, bool isdynamic) const override;
   bool containsExternalFunction() const override;
   void collectVARLHSVariable(set<expr_t> &result) const override;
   void collectDynamicVariables(SymbolType type_arg, set<pair<int, int>> &result) const override;
@@ -787,7 +809,7 @@ public:
   void prepareForDerivation() override;
   void writeOutput(ostream &output, ExprNodeOutputType output_type, const temporary_terms_t &temporary_terms, const temporary_terms_idxs_t &temporary_terms_idxs, const deriv_node_temp_terms_t &tef_terms) const override;
   void writeJsonAST(ostream &output) const override;
-  void writeJsonOutput(ostream &output, const temporary_terms_t &temporary_terms, const deriv_node_temp_terms_t &tef_terms, const bool isdynamic) const override;
+  void writeJsonOutput(ostream &output, const temporary_terms_t &temporary_terms, const deriv_node_temp_terms_t &tef_terms, bool isdynamic) const override;
   bool containsExternalFunction() const override;
   void collectVARLHSVariable(set<expr_t> &result) const override;
   void collectDynamicVariables(SymbolType type_arg, set<pair<int, int>> &result) const override;
@@ -883,7 +905,7 @@ public:
                              bool is_matlab) const override;
   void writeOutput(ostream &output, ExprNodeOutputType output_type, const temporary_terms_t &temporary_terms, const temporary_terms_idxs_t &temporary_terms_idxs, const deriv_node_temp_terms_t &tef_terms) const override;
   void writeJsonAST(ostream &output) const override;
-  void writeJsonOutput(ostream &output, const temporary_terms_t &temporary_terms, const deriv_node_temp_terms_t &tef_terms, const bool isdynamic) const override;
+  void writeJsonOutput(ostream &output, const temporary_terms_t &temporary_terms, const deriv_node_temp_terms_t &tef_terms, bool isdynamic) const override;
   bool containsExternalFunction() const override;
   void writeExternalFunctionOutput(ostream &output, ExprNodeOutputType output_type,
                                            const temporary_terms_t &temporary_terms,
@@ -892,7 +914,7 @@ public:
   void writeJsonExternalFunctionOutput(vector<string> &efout,
                                                const temporary_terms_t &temporary_terms,
                                                deriv_node_temp_terms_t &tef_terms,
-                                               const bool isdynamic) const override;
+                                               bool isdynamic) const override;
   void compileExternalFunctionOutput(ostream &CompileCode, unsigned int &instruction_number,
                                              bool lhs_rhs, const temporary_terms_t &temporary_terms,
                                              const map_idx_t &map_idx, bool dynamic, bool steady_dynamic,
@@ -994,7 +1016,7 @@ public:
                              bool is_matlab) const override;
   void writeOutput(ostream &output, ExprNodeOutputType output_type, const temporary_terms_t &temporary_terms, const temporary_terms_idxs_t &temporary_terms_idxs, const deriv_node_temp_terms_t &tef_terms) const override;
   void writeJsonAST(ostream &output) const override;
-  void writeJsonOutput(ostream &output, const temporary_terms_t &temporary_terms, const deriv_node_temp_terms_t &tef_terms, const bool isdynamic) const override;
+  void writeJsonOutput(ostream &output, const temporary_terms_t &temporary_terms, const deriv_node_temp_terms_t &tef_terms, bool isdynamic) const override;
   bool containsExternalFunction() const override;
   void writeExternalFunctionOutput(ostream &output, ExprNodeOutputType output_type,
                                            const temporary_terms_t &temporary_terms,
@@ -1003,7 +1025,7 @@ public:
   void writeJsonExternalFunctionOutput(vector<string> &efout,
                                                const temporary_terms_t &temporary_terms,
                                                deriv_node_temp_terms_t &tef_terms,
-                                               const bool isdynamic) const override;
+                                               bool isdynamic) const override;
   void compileExternalFunctionOutput(ostream &CompileCode, unsigned int &instruction_number,
                                              bool lhs_rhs, const temporary_terms_t &temporary_terms,
                                              const map_idx_t &map_idx, bool dynamic, bool steady_dynamic,
@@ -1126,7 +1148,7 @@ public:
                              bool is_matlab) const override;
   void writeOutput(ostream &output, ExprNodeOutputType output_type, const temporary_terms_t &temporary_terms, const temporary_terms_idxs_t &temporary_terms_idxs, const deriv_node_temp_terms_t &tef_terms) const override;
   void writeJsonAST(ostream &output) const override;
-  void writeJsonOutput(ostream &output, const temporary_terms_t &temporary_terms, const deriv_node_temp_terms_t &tef_terms, const bool isdynamic) const override;
+  void writeJsonOutput(ostream &output, const temporary_terms_t &temporary_terms, const deriv_node_temp_terms_t &tef_terms, bool isdynamic) const override;
   bool containsExternalFunction() const override;
   void writeExternalFunctionOutput(ostream &output, ExprNodeOutputType output_type,
                                            const temporary_terms_t &temporary_terms,
@@ -1135,7 +1157,7 @@ public:
   void writeJsonExternalFunctionOutput(vector<string> &efout,
                                                const temporary_terms_t &temporary_terms,
                                                deriv_node_temp_terms_t &tef_terms,
-                                               const bool isdynamic) const override;
+                                               bool isdynamic) const override;
   void compileExternalFunctionOutput(ostream &CompileCode, unsigned int &instruction_number,
                                              bool lhs_rhs, const temporary_terms_t &temporary_terms,
                                              const map_idx_t &map_idx, bool dynamic, bool steady_dynamic,
@@ -1227,7 +1249,7 @@ protected:
   //! Helper function to write output arguments of any given external function
   void writeExternalFunctionArguments(ostream &output, ExprNodeOutputType output_type, const temporary_terms_t &temporary_terms, const temporary_terms_idxs_t &temporary_terms_idxs, const deriv_node_temp_terms_t &tef_terms) const;
   void writeJsonASTExternalFunctionArguments(ostream &output) const;
-  void writeJsonExternalFunctionArguments(ostream &output, const temporary_terms_t &temporary_terms, const deriv_node_temp_terms_t &tef_terms, const bool isdynamic) const;
+  void writeJsonExternalFunctionArguments(ostream &output, const temporary_terms_t &temporary_terms, const deriv_node_temp_terms_t &tef_terms, bool isdynamic) const;
   /*! Returns a predicate that tests whether an other ExprNode is an external
     function which is computed by the same external function call (i.e. it has
     the same so-called "Tef" index) */
@@ -1242,7 +1264,7 @@ public:
                              bool is_matlab) const override;
   void writeOutput(ostream &output, ExprNodeOutputType output_type, const temporary_terms_t &temporary_terms, const temporary_terms_idxs_t &temporary_terms_idxs, const deriv_node_temp_terms_t &tef_terms) const override = 0;
   void writeJsonAST(ostream &output) const override = 0;
-  void writeJsonOutput(ostream &output, const temporary_terms_t &temporary_terms, const deriv_node_temp_terms_t &tef_terms, const bool isdynamic = true) const override = 0;
+  void writeJsonOutput(ostream &output, const temporary_terms_t &temporary_terms, const deriv_node_temp_terms_t &tef_terms, bool isdynamic = true) const override = 0;
   bool containsExternalFunction() const override;
   void writeExternalFunctionOutput(ostream &output, ExprNodeOutputType output_type,
                                            const temporary_terms_t &temporary_terms,
@@ -1251,7 +1273,7 @@ public:
   void writeJsonExternalFunctionOutput(vector<string> &efout,
                                                const temporary_terms_t &temporary_terms,
                                                deriv_node_temp_terms_t &tef_terms,
-                                               const bool isdynamic = true) const override = 0;
+                                               bool isdynamic = true) const override = 0;
   void compileExternalFunctionOutput(ostream &CompileCode, unsigned int &instruction_number,
                                              bool lhs_rhs, const temporary_terms_t &temporary_terms,
                                              const map_idx_t &map_idx, bool dynamic, bool steady_dynamic,
@@ -1339,7 +1361,7 @@ public:
                        const vector<expr_t> &arguments_arg);
   void writeOutput(ostream &output, ExprNodeOutputType output_type, const temporary_terms_t &temporary_terms, const temporary_terms_idxs_t &temporary_terms_idxs, const deriv_node_temp_terms_t &tef_terms) const override;
   void writeJsonAST(ostream &output) const override;
-  void writeJsonOutput(ostream &output, const temporary_terms_t &temporary_terms, const deriv_node_temp_terms_t &tef_terms, const bool isdynamic) const override;
+  void writeJsonOutput(ostream &output, const temporary_terms_t &temporary_terms, const deriv_node_temp_terms_t &tef_terms, bool isdynamic) const override;
   void writeExternalFunctionOutput(ostream &output, ExprNodeOutputType output_type,
                                            const temporary_terms_t &temporary_terms,
                                            const temporary_terms_idxs_t &temporary_terms_idxs,
@@ -1347,7 +1369,7 @@ public:
   void writeJsonExternalFunctionOutput(vector<string> &efout,
                                                const temporary_terms_t &temporary_terms,
                                                deriv_node_temp_terms_t &tef_terms,
-                                               const bool isdynamic) const override;
+                                               bool isdynamic) const override;
   void compileExternalFunctionOutput(ostream &CompileCode, unsigned int &instruction_number,
                                              bool lhs_rhs, const temporary_terms_t &temporary_terms,
                                              const map_idx_t &map_idx, bool dynamic, bool steady_dynamic,
@@ -1386,7 +1408,7 @@ public:
                                      int equation) const override;
   void writeOutput(ostream &output, ExprNodeOutputType output_type, const temporary_terms_t &temporary_terms, const temporary_terms_idxs_t &temporary_terms_idxs, const deriv_node_temp_terms_t &tef_terms) const override;
   void writeJsonAST(ostream &output) const override;
-  void writeJsonOutput(ostream &output, const temporary_terms_t &temporary_terms, const deriv_node_temp_terms_t &tef_terms, const bool isdynamic) const override;
+  void writeJsonOutput(ostream &output, const temporary_terms_t &temporary_terms, const deriv_node_temp_terms_t &tef_terms, bool isdynamic) const override;
   void compile(ostream &CompileCode, unsigned int &instruction_number,
                        bool lhs_rhs, const temporary_terms_t &temporary_terms,
                        const map_idx_t &map_idx, bool dynamic, bool steady_dynamic,
@@ -1398,7 +1420,7 @@ public:
   void writeJsonExternalFunctionOutput(vector<string> &efout,
                                                const temporary_terms_t &temporary_terms,
                                                deriv_node_temp_terms_t &tef_terms,
-                                               const bool isdynamic) const override;
+                                               bool isdynamic) const override;
   void compileExternalFunctionOutput(ostream &CompileCode, unsigned int &instruction_number,
                                              bool lhs_rhs, const temporary_terms_t &temporary_terms,
                                              const map_idx_t &map_idx, bool dynamic, bool steady_dynamic,
@@ -1432,7 +1454,7 @@ public:
                                      int equation) const override;
   void writeOutput(ostream &output, ExprNodeOutputType output_type, const temporary_terms_t &temporary_terms, const temporary_terms_idxs_t &temporary_terms_idxs, const deriv_node_temp_terms_t &tef_terms) const override;
   void writeJsonAST(ostream &output) const override;
-  void writeJsonOutput(ostream &output, const temporary_terms_t &temporary_terms, const deriv_node_temp_terms_t &tef_terms, const bool isdynamic) const override;
+  void writeJsonOutput(ostream &output, const temporary_terms_t &temporary_terms, const deriv_node_temp_terms_t &tef_terms, bool isdynamic) const override;
   void compile(ostream &CompileCode, unsigned int &instruction_number,
                        bool lhs_rhs, const temporary_terms_t &temporary_terms,
                        const map_idx_t &map_idx, bool dynamic, bool steady_dynamic,
@@ -1444,7 +1466,7 @@ public:
   void writeJsonExternalFunctionOutput(vector<string> &efout,
                                                const temporary_terms_t &temporary_terms,
                                                deriv_node_temp_terms_t &tef_terms,
-                                               const bool isdynamic) const override;
+                                               bool isdynamic) const override;
   void compileExternalFunctionOutput(ostream &CompileCode, unsigned int &instruction_number,
                                              bool lhs_rhs, const temporary_terms_t &temporary_terms,
                                              const map_idx_t &map_idx, bool dynamic, bool steady_dynamic,
@@ -1532,7 +1554,7 @@ public:
   void getEndosAndMaxLags(map<string, int> &model_endos_and_lags) const override;
   expr_t substituteStaticAuxiliaryVariable() const override;
   void writeJsonAST(ostream &output) const override;
-  void writeJsonOutput(ostream &output, const temporary_terms_t &temporary_terms, const deriv_node_temp_terms_t &tef_terms, const bool isdynamic) const override;
+  void writeJsonOutput(ostream &output, const temporary_terms_t &temporary_terms, const deriv_node_temp_terms_t &tef_terms, bool isdynamic) const override;
 };
 
 class PacExpectationNode : public ExprNode
@@ -1613,7 +1635,7 @@ public:
   void getEndosAndMaxLags(map<string, int> &model_endos_and_lags) const override;
   expr_t substituteStaticAuxiliaryVariable() const override;
   void writeJsonAST(ostream &output) const override;
-  void writeJsonOutput(ostream &output, const temporary_terms_t &temporary_terms, const deriv_node_temp_terms_t &tef_terms, const bool isdynamic) const override;
+  void writeJsonOutput(ostream &output, const temporary_terms_t &temporary_terms, const deriv_node_temp_terms_t &tef_terms, bool isdynamic) const override;
 };
 
 #endif
diff --git a/src/ExternalFunctionsTable.hh b/src/ExternalFunctionsTable.hh
index bd6c64c60ef67dc0e70836463cf9997cd2223f91..61d50d5efcfee18f6b7a32f8245fdf8bb71d341f 100644
--- a/src/ExternalFunctionsTable.hh
+++ b/src/ExternalFunctionsTable.hh
@@ -1,5 +1,5 @@
 /*
- * Copyright © 2010-2015 Dynare Team
+ * Copyright © 2010-2019 Dynare Team
  *
  * This file is part of Dynare.
  *
@@ -79,8 +79,7 @@ public:
 inline bool
 ExternalFunctionsTable::exists(int symb_id) const
 {
-  auto iter = externalFunctionTable.find(symb_id);
-  return (iter != externalFunctionTable.end());
+  return externalFunctionTable.find(symb_id) != externalFunctionTable.end();
 }
 
 inline int
@@ -114,7 +113,7 @@ inline int
 ExternalFunctionsTable::get_total_number_of_unique_model_block_external_functions() const
 {
   int number_of_unique_model_block_external_functions = 0;
-  for (auto it : externalFunctionTable)
+  for (const auto &it : externalFunctionTable)
     if (it.second.nargs > 0)
       number_of_unique_model_block_external_functions++;
 
diff --git a/src/MinimumFeedbackSet.cc b/src/MinimumFeedbackSet.cc
index 7b2b3e2b28fc0b7be31c9c4e29ad4f6ce9638d46..7f7f41fb99e01cac974b90569e643754d9275012 100644
--- a/src/MinimumFeedbackSet.cc
+++ b/src/MinimumFeedbackSet.cc
@@ -1,5 +1,5 @@
 /*
- * Copyright © 2009-2017 Dynare Team
+ * Copyright © 2009-2019 Dynare Team
  *
  * This file is part of Dynare.
  *
@@ -102,9 +102,9 @@ namespace MFS
   Print(AdjacencyList_t &G)
   {
     AdjacencyList_t::vertex_iterator  it, it_end;
-    property_map<AdjacencyList_t, vertex_index_t>::type v_index = get(vertex_index, G);
-    cout << "Graph\n";
-    cout << "-----\n";
+    auto v_index = get(vertex_index, G);
+    cout << "Graph\n"
+         << "-----\n";
     for (tie(it, it_end) = vertices(G); it != it_end; ++it)
       {
         cout << "vertex[" << v_index[*it] + 1 << "] <-";
@@ -123,8 +123,8 @@ namespace MFS
   AM_2_AdjacencyList(bool *AM, unsigned int n)
   {
     AdjacencyList_t G(n);
-    property_map<AdjacencyList_t, vertex_index_t>::type v_index = get(vertex_index, G);
-    property_map<AdjacencyList_t, vertex_index1_t>::type v_index1 = get(vertex_index1, G);
+    auto v_index = get(vertex_index, G);
+    auto v_index1 = get(vertex_index1, G);
     for (unsigned int i = 0; i < n; i++)
       {
         put(v_index, vertex(i, G), i);
@@ -142,9 +142,9 @@ namespace MFS
   {
     unsigned int n = select_index.size();
     AdjacencyList_t G(n);
-    property_map<AdjacencyList_t, vertex_index_t>::type v_index = get(vertex_index, G);
-    property_map<AdjacencyList_t, vertex_index1_t>::type v_index1 = get(vertex_index1, G);
-    property_map<AdjacencyList_t, vertex_index_t>::type v1_index = get(vertex_index, G1);
+    auto v_index = get(vertex_index, G);
+    auto v_index1 = get(vertex_index1, G);
+    auto v1_index = get(vertex_index, G1);
     map<int, int> reverse_index;
     set<int>::iterator it;
     unsigned int i;
@@ -157,7 +157,7 @@ namespace MFS
     for (it = select_index.begin(), i = 0; i < n; i++, ++it)
       {
         AdjacencyList_t::out_edge_iterator it_out, out_end;
-        AdjacencyList_t::vertex_descriptor vi = vertex(*it, G1);
+        auto vi = vertex(*it, G1);
         for (tie(it_out, out_end) = out_edges(vi, G1); it_out != out_end; ++it_out)
           {
             int ii = v1_index[target(*it_out, G1)];
@@ -177,7 +177,7 @@ namespace MFS
     if (in_degree(vertex, G) > 0 && out_degree(vertex, G) > 0)
       for (tie(it_in, in_end) = in_edges(vertex, G); it_in != in_end; ++it_in)
         for (tie(it_out, out_end) = out_edges(vertex, G); it_out != out_end; ++it_out)
-          if (source(*it_in, G) == target(*it_out, G) && source(*it_in, G) != target(*it_in, G))                                                                                                                                                                                                                                                                                                                                                                                                         // not a loop
+          if (source(*it_in, G) == target(*it_out, G) && source(*it_in, G) != target(*it_in, G)) // not a loop
             Doublet.push_back(source(*it_in, G));
     return Doublet;
   }
@@ -227,7 +227,7 @@ namespace MFS
     bool something_has_been_done = false;
     bool not_a_loop;
     int i;
-    AdjacencyList_t::vertex_iterator  it, it1, ita, it_end;
+    AdjacencyList_t::vertex_iterator it, it1, ita, it_end;
     for (tie(it, it_end) = vertices(G), i = 0; it != it_end; ++it, i++)
       {
         int in_degree_n = in_degree(*it, G);
@@ -250,7 +250,7 @@ namespace MFS
             if (not_a_loop)
               {
 #ifdef verbose
-                property_map<AdjacencyList_t, vertex_index_t>::type v_index = get(vertex_index, G);
+                auto v_index = get(vertex_index, G);
                 cout << "->eliminate vertex[" << v_index[*it] + 1 << "]\n";
 #endif
                 Eliminate(*it, G);
@@ -275,7 +275,7 @@ namespace MFS
   bool
   Elimination_of_Vertex_belonging_to_a_clique_Step(AdjacencyList_t &G)
   {
-    AdjacencyList_t::vertex_iterator  it, it1, ita, it_end;
+    AdjacencyList_t::vertex_iterator it, it1, ita, it_end;
     bool something_has_been_done = false;
     int i;
     for (tie(it, it_end) = vertices(G), i = 0; it != it_end; ++it, i++)
@@ -283,7 +283,7 @@ namespace MFS
         if (Vertex_Belong_to_a_Clique(*it, G))
           {
 #ifdef verbose
-            property_map<AdjacencyList_t, vertex_index_t>::type v_index = get(vertex_index, G);
+            auto v_index = get(vertex_index, G);
             cout << "eliminate vertex[" << v_index[*it] + 1 << "]\n";
 #endif
             Eliminate(*it, G);
@@ -305,7 +305,7 @@ namespace MFS
   Suppression_of_Vertex_X_if_it_loops_store_in_set_of_feedback_vertex_Step(set<int> &feed_back_vertices, AdjacencyList_t &G)
   {
     bool something_has_been_done = false;
-    AdjacencyList_t::vertex_iterator  it, it_end, ita;
+    AdjacencyList_t::vertex_iterator it, it_end, ita;
     int i = 0;
     for (tie(it, it_end) = vertices(G); it != it_end; ++it, i++)
       {
@@ -315,13 +315,11 @@ namespace MFS
         if (exist)
           {
 #ifdef verbose
-            property_map<AdjacencyList_t, vertex_index_t>::type v_index = get(vertex_index, G);
+            auto v_index = get(vertex_index, G);
             cout << "store v[*it] = " << v_index[*it]+1 << "\n";
 #endif
-            property_map<AdjacencyList_t, vertex_index1_t>::type v_index1 = get(vertex_index1, G);
+            auto v_index1 = get(vertex_index1, G);
             feed_back_vertices.insert(v_index1[*it]);
-            /*property_map<AdjacencyList_t, vertex_index_t>::type v_index = get(vertex_index, G);
-              feed_back_vertices.insert(v_index[*it] );*/
             Suppress(*it, G);
             something_has_been_done = true;
             if (i > 0)
@@ -349,7 +347,7 @@ namespace MFS
         while (something_has_been_done && num_vertices(G) > 0)
           {
             //Rule 1
-            something_has_been_done = (Elimination_of_Vertex_With_One_or_Less_Indegree_or_Outdegree_Step(G) /*or something_has_been_done*/);
+            something_has_been_done = Elimination_of_Vertex_With_One_or_Less_Indegree_or_Outdegree_Step(G) /*or something_has_been_done*/;
 #ifdef verbose
             cout << "1 something_has_been_done=" << something_has_been_done << "\n";
 #endif
@@ -379,23 +377,19 @@ namespace MFS
           {
             /*if nothing has been done in the five previous rule then cut the vertex with the maximum in_degree+out_degree*/
             unsigned int max_degree = 0, num = 0;
-            AdjacencyList_t::vertex_iterator  it, it_end, max_degree_index;
+            AdjacencyList_t::vertex_iterator it, it_end, max_degree_index;
             for (tie(it, it_end) = vertices(G); it != it_end; ++it, num++)
-              {
-                if (in_degree(*it, G) + out_degree(*it, G) > max_degree)
-                  {
-                    max_degree = in_degree(*it, G) + out_degree(*it, G);
-                    max_degree_index = it;
-                  }
-              }
-            property_map<AdjacencyList_t, vertex_index1_t>::type v_index1 = get(vertex_index1, G);
+              if (in_degree(*it, G) + out_degree(*it, G) > max_degree)
+                {
+                  max_degree = in_degree(*it, G) + out_degree(*it, G);
+                  max_degree_index = it;
+                }
+
+            auto v_index1 = get(vertex_index1, G);
             feed_back_vertices.insert(v_index1[*max_degree_index]);
-            /*property_map<AdjacencyList_t, vertex_index_t>::type v_index = get(vertex_index, G);
-              feed_back_vertices.insert(v_index[*max_degree_index]);*/
-            //cout << "v_index1[*max_degree_index] = " << v_index1[*max_degree_index] << "\n";
             cut_++;
 #ifdef verbose
-            property_map<AdjacencyList_t, vertex_index_t>::type v_index = get(vertex_index, G);
+            auto v_index = get(vertex_index, G);
             cout << "--> cut vertex " << v_index[*max_degree_index] + 1 << "\n";
 #endif
             Suppress(*max_degree_index, G);
@@ -414,7 +408,7 @@ namespace MFS
     bool
     operator()(const int a, const int b) const
     {
-      return (a > b);
+      return a > b;
     }
   };
 
@@ -422,19 +416,18 @@ namespace MFS
   Reorder_the_recursive_variables(const AdjacencyList_t &G1, set<int> &feedback_vertices, vector< int> &Reordered_Vertices)
   {
     AdjacencyList_t G(G1);
-    property_map<AdjacencyList_t, vertex_index_t>::type v_index = get(vertex_index, G);
-    set<int>::iterator its, ita;
+    auto v_index = get(vertex_index, G);
     set<int, rev> fv;
-    for (its = feedback_vertices.begin(); its != feedback_vertices.end(); its++)
+    for (auto its = feedback_vertices.begin(); its != feedback_vertices.end(); ++its)
       fv.insert(*its);
     int i = 0;
-    for (its = fv.begin(); its != fv.end(); ++its, i++)
+    for (auto its = fv.begin(); its != fv.end(); ++its, i++)
       Suppress(*its, G);
     bool something_has_been_done = true;
     while (something_has_been_done)
       {
         something_has_been_done = false;
-        AdjacencyList_t::vertex_iterator  it, it_end, ita;
+        AdjacencyList_t::vertex_iterator it, it_end, ita;
         for (tie(it, it_end) = vertices(G), i = 0; it != it_end; ++it, i++)
           {
             if (in_degree(*it, G) == 0)
diff --git a/src/ModFile.cc b/src/ModFile.cc
index 14f776a565fa435e3edf6efa3015dffc833ae22d..dd43b49686edaf23481dbec2679bba5ef9e51c77 100644
--- a/src/ModFile.cc
+++ b/src/ModFile.cc
@@ -204,12 +204,11 @@ ModFile::checkPass(bool nostrict, bool stochastic)
       exit(EXIT_FAILURE);
     }
 
-  if (block || byte_code)
-    if (dynamic_model.isModelLocalVariableUsed())
-      {
-        cerr << "ERROR: In 'model' block, 'block' or 'bytecode' options are not yet compatible with pound expressions" << endl;
-        exit(EXIT_FAILURE);
-      }
+  if ((block || byte_code) && dynamic_model.isModelLocalVariableUsed())
+    {
+      cerr << "ERROR: In 'model' block, 'block' or 'bytecode' options are not yet compatible with pound expressions" << endl;
+      exit(EXIT_FAILURE);
+    }
 
   if ((stochastic_statement_present || mod_file_struct.check_present || mod_file_struct.steady_present) && no_static)
     {
@@ -217,13 +216,12 @@ ModFile::checkPass(bool nostrict, bool stochastic)
       exit(EXIT_FAILURE);
     }
 
-  if (mod_file_struct.dsge_var_estimated)
-    if (!mod_file_struct.dsge_prior_weight_in_estimated_params)
-      {
-        cerr << "ERROR: When estimating a DSGE-VAR model and estimating the weight of the prior, dsge_prior_weight must "
-             << "be referenced in the estimated_params block." << endl;
-        exit(EXIT_FAILURE);
-      }
+  if (mod_file_struct.dsge_var_estimated && !mod_file_struct.dsge_prior_weight_in_estimated_params)
+    {
+      cerr << "ERROR: When estimating a DSGE-VAR model and estimating the weight of the prior, dsge_prior_weight must "
+           << "be referenced in the estimated_params block." << endl;
+      exit(EXIT_FAILURE);
+    }
 
   if (symbol_table.exists("dsge_prior_weight"))
     {
@@ -381,7 +379,7 @@ ModFile::checkPass(bool nostrict, bool stochastic)
 }
 
 void
-ModFile::transformPass(bool nostrict, bool stochastic, bool compute_xrefs, const bool transform_unary_ops,
+ModFile::transformPass(bool nostrict, bool stochastic, bool compute_xrefs, bool transform_unary_ops,
                        const string &exclude_eqs, const string &include_eqs)
 {
   /* Save the original model (must be done before any model transformations by preprocessor)
@@ -418,11 +416,11 @@ ModFile::transformPass(bool nostrict, bool stochastic, bool compute_xrefs, const
   // Declare endogenous used for PAC model-consistent expectations
   for (auto & statement : statements)
     if (auto pms = dynamic_cast<PacModelStatement *>(statement.get());
-        pms != nullptr)
+        pms)
       {
-        if (pms->growth != nullptr)
+        if (pms->growth)
           pac_growth.push_back(pms->growth);
-        if (pms->aux_model_name == "")
+        if (pms->aux_model_name.empty())
           dynamic_model.declarePacModelConsistentExpectationEndogs(pms->name);
       }
 
@@ -458,9 +456,9 @@ ModFile::transformPass(bool nostrict, bool stochastic, bool compute_xrefs, const
   // Pac Model
   int i = 0;
   for (auto & statement : statements)
-    if (auto pms = dynamic_cast<PacModelStatement *>(statement.get()); pms != nullptr)
+    if (auto pms = dynamic_cast<PacModelStatement *>(statement.get()); pms)
       {
-        if (pms->growth != nullptr)
+        if (pms->growth)
           pms->overwriteGrowth(pac_growth.at(i++));
 
         int max_lag;
@@ -483,7 +481,7 @@ ModFile::transformPass(bool nostrict, bool stochastic, bool compute_xrefs, const
             // nonstationary variables in a VAR are those that are in diff
             nonstationary = var_model_table.getDiff(pms->aux_model_name);
           }
-        else if (pms->aux_model_name == "")
+        else if (pms->aux_model_name.empty())
           max_lag = 0;
         else
           {
@@ -492,7 +490,7 @@ ModFile::transformPass(bool nostrict, bool stochastic, bool compute_xrefs, const
           }
         auto eqtag_and_lag = dynamic_model.walkPacParameters(pms->name);
         original_model.getPacMaxLag(pms->name, eqtag_and_lag);
-        if (pms->aux_model_name == "")
+        if (pms->aux_model_name.empty())
           dynamic_model.addPacModelConsistentExpectationEquation(pms->name, symbol_table.getID(pms->discount),
                                                                  eqtag_and_lag, diff_subst_table);
         else
@@ -526,15 +524,15 @@ ModFile::transformPass(bool nostrict, bool stochastic, bool compute_xrefs, const
     {
       PlannerObjectiveStatement *pos = nullptr;
       for (auto & statement : statements)
-        if (auto pos2 = dynamic_cast<PlannerObjectiveStatement *>(statement.get()); pos2 != nullptr)
-          if (pos != nullptr)
+        if (auto pos2 = dynamic_cast<PlannerObjectiveStatement *>(statement.get()); pos2)
+          if (pos)
             {
               cerr << "ERROR: there can only be one planner_objective statement" << endl;
               exit(EXIT_FAILURE);
             }
           else
             pos = pos2;
-      assert(pos != nullptr);
+      assert(pos);
       const StaticModel &planner_objective = pos->getPlannerObjective();
 
       /*
@@ -694,7 +692,7 @@ ModFile::transformPass(bool nostrict, bool stochastic, bool compute_xrefs, const
 
   if (mod_file_struct.ramsey_policy_present)
     for (auto & statement : statements)
-      if (auto *rps = dynamic_cast<RamseyPolicyStatement *>(statement.get()); rps != nullptr)
+      if (auto rps = dynamic_cast<RamseyPolicyStatement *>(statement.get()); rps)
         rps->checkRamseyPolicyList();
 
   if (mod_file_struct.identification_present && symbol_table.exo_det_nbr() > 0)
@@ -1036,7 +1034,7 @@ ModFile::writeOutputFiles(const string &basename, bool clear_all, bool clear_glo
       {
         /* Special treatment for initval block: insert initial values for the
            auxiliary variables and initialize exo det */
-        if (auto *ivs = dynamic_cast<InitValStatement *>(statement.get()); ivs != nullptr)
+        if (auto ivs = dynamic_cast<InitValStatement *>(statement.get()); ivs)
           {
             ivs->writeOutput(mOutputFile, basename, minimal_workspace);
             static_model.writeAuxVarInitval(mOutputFile, ExprNodeOutputType::matlabOutsideModel);
@@ -1044,22 +1042,22 @@ ModFile::writeOutputFiles(const string &basename, bool clear_all, bool clear_glo
           }
 
         // Special treatment for endval block: insert initial values for the auxiliary variables
-        if (auto *evs = dynamic_cast<EndValStatement *>(statement.get()); evs != nullptr)
+        if (auto evs = dynamic_cast<EndValStatement *>(statement.get()); evs)
           {
             evs->writeOutput(mOutputFile, basename, minimal_workspace);
             static_model.writeAuxVarInitval(mOutputFile, ExprNodeOutputType::matlabOutsideModel);
           }
 
-        if (auto *ips = dynamic_cast<InitParamStatement *>(statement.get()); ips != nullptr)
+        if (auto ips = dynamic_cast<InitParamStatement *>(statement.get()); ips)
           ips->writeOutput(mOutputFile, basename, minimal_workspace);
 
-        if (auto *ss = dynamic_cast<ShocksStatement *>(statement.get()); ss != nullptr)
+        if (auto ss = dynamic_cast<ShocksStatement *>(statement.get()); ss)
           ss->writeOutput(mOutputFile, basename, minimal_workspace);
 
-        if (auto *eps = dynamic_cast<EstimatedParamsStatement *>(statement.get()); eps != nullptr)
+        if (auto eps = dynamic_cast<EstimatedParamsStatement *>(statement.get()); eps)
           eps->writeOutput(mOutputFile, basename, minimal_workspace);
 
-        if (auto *sgs = dynamic_cast<ShockGroupsStatement *>(statement.get()); sgs != nullptr)
+        if (auto sgs = dynamic_cast<ShockGroupsStatement *>(statement.get()); sgs)
           sgs->writeOutput(mOutputFile, basename, minimal_workspace);
       }
   else
@@ -1070,14 +1068,14 @@ ModFile::writeOutputFiles(const string &basename, bool clear_all, bool clear_glo
 
           /* Special treatment for initval block: insert initial values for the
              auxiliary variables and initialize exo det */
-          if (auto ivs = dynamic_cast<InitValStatement *>(statement.get()); ivs != nullptr)
+          if (auto ivs = dynamic_cast<InitValStatement *>(statement.get()); ivs)
             {
               static_model.writeAuxVarInitval(mOutputFile, ExprNodeOutputType::matlabOutsideModel);
               ivs->writeOutputPostInit(mOutputFile);
             }
 
           // Special treatment for endval block: insert initial values for the auxiliary variables
-          if (auto evs = dynamic_cast<EndValStatement *>(statement.get()); evs != nullptr)
+          if (auto evs = dynamic_cast<EndValStatement *>(statement.get()); evs)
             static_model.writeAuxVarInitval(mOutputFile, ExprNodeOutputType::matlabOutsideModel);
 
           // Special treatment for load params and steady state statement: insert initial values for the auxiliary variables
@@ -1369,8 +1367,7 @@ ModFile::writeJsonOutputParsingCheck(const string &basename, JsonFileOutputType
           output << ", ";
         }
 
-      for (auto it = statements.begin();
-           it != statements.end(); it++)
+      for (auto it = statements.begin(); it != statements.end(); ++it)
         {
           if (it != statements.begin())
             output << ", " << endl;
@@ -1522,14 +1519,11 @@ ModFile::writeJsonComputingPassOutput(const string &basename, JsonFileOutputType
   dynamic_model.writeJsonComputingPassOutput(dynamic_output, !jsonderivsimple);
   dynamic_output << "}";
 
-  tmp_out << "";
-  static_paramsd_output << "";
   static_model.writeJsonParamsDerivativesFile(tmp_out, !jsonderivsimple);
   if (!tmp_out.str().empty())
     static_paramsd_output << "{" << tmp_out.str() << "}" << endl;
 
   tmp_out.str("");
-  dynamic_paramsd_output << "";
   dynamic_model.writeJsonParamsDerivativesFile(tmp_out, !jsonderivsimple);
   if (!tmp_out.str().empty())
     dynamic_paramsd_output << "{" << tmp_out.str() << "}" << endl;
diff --git a/src/ModFile.hh b/src/ModFile.hh
index e177934ef3b960a51fd5c71e9e88aebb7b65900a..7eaa88b376c45c31fec271a6fb318367b2eb5b34 100644
--- a/src/ModFile.hh
+++ b/src/ModFile.hh
@@ -146,7 +146,7 @@ public:
   void checkPass(bool nostrict, bool stochastic);
   //! Perform some transformations on the model (creation of auxiliary vars and equations)
   /*! \param compute_xrefs if true, equation cross references will be computed */
-  void transformPass(bool nostrict, bool stochastic, bool compute_xrefs, const bool transform_unary_ops,
+  void transformPass(bool nostrict, bool stochastic, bool compute_xrefs, bool transform_unary_ops,
                      const string &exclude_eqs, const string &include_eqs);
   //! Execute computations
   /*! \param no_tmp_terms if true, no temporary terms will be computed in the static and dynamic files */
diff --git a/src/ModelEquationBlock.cc b/src/ModelEquationBlock.cc
index 04f257406cc0d88c52baeed9d5947ffd80a431f8..6e3adece89d60fc86aa42d0f919c712e2994ffcb 100644
--- a/src/ModelEquationBlock.cc
+++ b/src/ModelEquationBlock.cc
@@ -166,11 +166,9 @@ SteadyStateModel::writeLatexSteadyStateFile(const string &basename) const
          << "\\begin{document}" << endl
          << "\\footnotesize" << endl;
 
-  for (const auto & it : def_table)
-    for (auto it1 = it.first.begin(); it1 != it.first.end(); it1++)
+  for (const auto & [ids, value] : def_table)
+    for (int id : ids)
       {
-        int id = *it1;
-        expr_t value = it.second;
         content_output << "\\begin{dmath}" << endl
                        << symbol_table.getTeXName(id) << " = ";
         value->writeOutput(content_output, ExprNodeOutputType::latexStaticModel);
@@ -218,9 +216,8 @@ SteadyStateModel::writeSteadyStateFile(const string &basename, bool ramsey_model
            << "function steady_state!(ys_::Vector{Float64}, exo_::Vector{Float64}, "
            << "params::Vector{Float64})" << endl;
 
-  for (const auto & i : def_table)
+  for (const auto & [symb_ids, value] : def_table)
     {
-      const vector<int> &symb_ids = i.first;
       output << "    ";
       if (symb_ids.size() > 1)
         output << "[";
@@ -234,7 +231,7 @@ SteadyStateModel::writeSteadyStateFile(const string &basename, bool ramsey_model
         output << "]";
 
       output << "=";
-      i.second->writeOutput(output, output_type);
+      value->writeOutput(output, output_type);
       output << ";" << endl;
     }
   if (!julia)
@@ -353,23 +350,23 @@ Epilogue::detrend(const map<int, expr_t> & trend_symbols_map,
                   const nonstationary_symbols_map_t & nonstationary_symbols_map)
 {
   for (auto it = nonstationary_symbols_map.crbegin();
-       it != nonstationary_symbols_map.crend(); it++)
+       it != nonstationary_symbols_map.crend(); ++it)
     for (auto & [symb_id, expr] : dynamic_def_table)
       {
         expr = expr->detrend(it->first, it->second.first, it->second.second);
-        assert(expr != nullptr);
+        assert(expr);
       }
 
   for (auto & [symb_id, expr] : dynamic_def_table)
     {
       expr = expr->removeTrendLeadLag(trend_symbols_map);
-      assert(expr != nullptr);
+      assert(expr);
     }
 
   for (auto & [symb_id, expr] : dynamic_def_table)
     {
       expr = expr->replaceTrendVar();
-      assert(expr != nullptr);
+      assert(expr);
     }
 }
 
@@ -445,7 +442,7 @@ Epilogue::writeDynamicEpilogueFile(const string & basename) const
       expr->collectVariables(SymbolType::epilogue, used_symbols);
 
       output << "simul_begin_date = firstobservedperiod(ds{";
-      for (auto it1 = used_symbols.begin(); it1 != used_symbols.end(); it1++)
+      for (auto it1 = used_symbols.begin(); it1 != used_symbols.end(); ++it1)
         {
           if (it1 != used_symbols.begin())
             output << ", ";
diff --git a/src/ModelTree.cc b/src/ModelTree.cc
index 113a11f0a5273714a8eaab40c2f2a7ae60130746..d4fd5c65df3b1b4feb12720ae3b7ada0c60621be 100644
--- a/src/ModelTree.cc
+++ b/src/ModelTree.cc
@@ -203,8 +203,7 @@ ModelTree::computeNormalization(const jacob_map_t &contemporaneous_jacobian, boo
 #else // Alternative way to compute normalization, by giving an initial matching using natural normalizations
   fill(mate_map.begin(), mate_map.end(), boost::graph_traits<BipartiteGraph>::null_vertex());
 
-  multimap<int, int> natural_endo2eqs;
-  computeNormalizedEquations(natural_endo2eqs);
+  auto natural_endo2eqs = computeNormalizedEquations();
 
   for (int i = 0; i < symbol_table.endo_nbr(); i++)
     {
@@ -240,8 +239,7 @@ ModelTree::computeNormalization(const jacob_map_t &contemporaneous_jacobian, boo
   transform(mate_map.begin(), mate_map.begin() + n, endo2eq.begin(), [=](int i) { return i-n; });
 
 #ifdef DEBUG
-  multimap<int, int> natural_endo2eqs;
-  computeNormalizedEquations(natural_endo2eqs);
+  auto natural_endo2eqs = computeNormalizedEquations(natural_endo2eqs);
 
   int n1 = 0, n2 = 0;
 
@@ -264,8 +262,8 @@ ModelTree::computeNormalization(const jacob_map_t &contemporaneous_jacobian, boo
 #endif
 
   // Check if all variables are normalized
-  auto it = find(mate_map.begin(), mate_map.begin() + n, boost::graph_traits<BipartiteGraph>::null_vertex());
-  if (it != mate_map.begin() + n)
+  if (auto it = find(mate_map.begin(), mate_map.begin() + n, boost::graph_traits<BipartiteGraph>::null_vertex());
+      it != mate_map.begin() + n)
     {
       if (verbose)
         cerr << "ERROR: Could not normalize the model. Variable "
@@ -339,22 +337,22 @@ ModelTree::computeNonSingularNormalization(jacob_map_t &contemporaneous_jacobian
       if (check)
         {
           // Update the jacobian matrix
-          for (const auto &it : tmp_normalized_contemporaneous_jacobian)
+          for (const auto &[key, ignore] : tmp_normalized_contemporaneous_jacobian)
             {
-              if (static_jacobian.find({ it.first.first, it.first.second }) == static_jacobian.end())
-                static_jacobian[{ it.first.first, it.first.second }] = 0;
-              if (dynamic_jacobian.find({ 0, it.first.first, it.first.second }) == dynamic_jacobian.end())
-                dynamic_jacobian[{ 0, it.first.first, it.first.second }] = nullptr;
-              if (contemporaneous_jacobian.find({ it.first.first, it.first.second }) == contemporaneous_jacobian.end())
-                contemporaneous_jacobian[{ it.first.first, it.first.second }] = 0;
+              if (static_jacobian.find({ key.first, key.second }) == static_jacobian.end())
+                static_jacobian[{ key.first, key.second }] = 0;
+              if (dynamic_jacobian.find({ 0, key.first, key.second }) == dynamic_jacobian.end())
+                dynamic_jacobian[{ 0, key.first, key.second }] = nullptr;
+              if (contemporaneous_jacobian.find({ key.first, key.second }) == contemporaneous_jacobian.end())
+                contemporaneous_jacobian[{ key.first, key.second }] = 0;
               try
                 {
-                  if (derivatives[1].find({ it.first.first, getDerivID(symbol_table.getID(SymbolType::endogenous, it.first.second), 0) }) == derivatives[1].end())
-                    derivatives[1][{ it.first.first, getDerivID(symbol_table.getID(SymbolType::endogenous, it.first.second), 0) }] = Zero;
+                  if (derivatives[1].find({ key.first, getDerivID(symbol_table.getID(SymbolType::endogenous, key.second), 0) }) == derivatives[1].end())
+                    derivatives[1][{ key.first, getDerivID(symbol_table.getID(SymbolType::endogenous, key.second), 0) }] = Zero;
                 }
               catch (DataTree::UnknownDerivIDException &e)
                 {
-                  cerr << "The variable " << symbol_table.getName(symbol_table.getID(SymbolType::endogenous, it.first.second))
+                  cerr << "The variable " << symbol_table.getName(symbol_table.getID(SymbolType::endogenous, key.second))
                        << " does not appear at the current period (i.e. with no lead and no lag); this case is not handled by the 'block' option of the 'model' block." << endl;
                   exit(EXIT_FAILURE);
                 }
@@ -369,13 +367,14 @@ ModelTree::computeNonSingularNormalization(jacob_map_t &contemporaneous_jacobian
     }
 }
 
-void
-ModelTree::computeNormalizedEquations(multimap<int, int> &endo2eqs) const
+multimap<int, int>
+ModelTree::computeNormalizedEquations() const
 {
+  multimap<int, int> endo2eqs;
   for (size_t i = 0; i < equations.size(); i++)
     {
-      auto *lhs = dynamic_cast<VariableNode *>(equations[i]->arg1);
-      if (lhs == nullptr)
+      auto lhs = dynamic_cast<VariableNode *>(equations[i]->arg1);
+      if (!lhs)
         continue;
 
       int symb_id = lhs->symb_id;
@@ -388,8 +387,9 @@ ModelTree::computeNormalizedEquations(multimap<int, int> &endo2eqs) const
         continue;
 
       endo2eqs.emplace(symbol_table.getTypeSpecificID(symb_id), static_cast<int>(i));
-      cout << "Endogenous " << symbol_table.getName(symb_id) << " normalized in equation " << (i+1) << endl;
+      cout << "Endogenous " << symbol_table.getName(symb_id) << " normalized in equation " << i+1 << endl;
     }
+  return endo2eqs;
 }
 
 void
@@ -397,20 +397,19 @@ ModelTree::evaluateAndReduceJacobian(const eval_context_t &eval_context, jacob_m
 {
   int nb_elements_contemparenous_Jacobian = 0;
   set<vector<int>> jacobian_elements_to_delete;
-  for (const auto &it : derivatives[1])
+  for (const auto &[indices, d1] : derivatives[1])
     {
-      int deriv_id = it.first[1];
+      int deriv_id = indices[1];
       if (getTypeByDerivID(deriv_id) == SymbolType::endogenous)
         {
-          expr_t Id = it.second;
-          int eq = it.first[0];
+          int eq = indices[0];
           int symb = getSymbIDByDerivID(deriv_id);
           int var = symbol_table.getTypeSpecificID(symb);
           int lag = getLagByDerivID(deriv_id);
           double val = 0;
           try
             {
-              val = Id->eval(eval_context);
+              val = d1->eval(eval_context);
             }
           catch (ExprNode::EvalExternalFunctionException &e)
             {
@@ -419,7 +418,7 @@ ModelTree::evaluateAndReduceJacobian(const eval_context_t &eval_context, jacob_m
           catch (ExprNode::EvalException &e)
             {
               cerr << "ERROR: evaluation of Jacobian failed for equation " << eq+1 << " (line " << equations_lineno[eq] << ") and variable " << symbol_table.getName(symb) << "(" << lag << ") [" << symb << "] !" << endl;
-              Id->writeOutput(cerr, ExprNodeOutputType::matlabDynamicModelSparse, temporary_terms, {});
+              d1->writeOutput(cerr, ExprNodeOutputType::matlabDynamicModelSparse, temporary_terms, {});
               cerr << endl;
               exit(EXIT_FAILURE);
             }
@@ -440,7 +439,7 @@ ModelTree::evaluateAndReduceJacobian(const eval_context_t &eval_context, jacob_m
                 static_jacobian[{ eq, var }] += val;
               else
                 static_jacobian[{ eq, var }] = val;
-              dynamic_jacobian[{ lag, eq, var }] = Id;
+              dynamic_jacobian[{ lag, eq, var }] = d1;
             }
         }
     }
@@ -470,34 +469,18 @@ ModelTree::select_non_linear_equations_and_variables(vector<bool> is_equation_li
     if (!is_equation_linear[it])
       num++;
   vector<int> endo2block = vector<int>(endo2eq.size(), 1);
-  vector<pair<set<int>, pair<set<int>, vector<int> > > > components_set(num);
+  vector<pair<set<int>, pair<set<int>, vector<int>>>> components_set(num);
   int i = 0, j = 0;
   for (auto it : endo2eq)
-    {
-      if (!is_equation_linear[it])
-        {
-          equation_reordered[i] = it;
-          variable_reordered[i] = j;
-          endo2block[j] = 0;
-          components_set[endo2block[j]].first.insert(i);
-          /*cout << " -----------------------------------------" << endl;
-          cout.flush();
-          cout << "equation_reordered[" << *it << "] = " << i << endl;
-          cout.flush();
-          cout << "variable_reordered[" << j << "] = " << i << endl;
-          cout.flush();
-          cout << "components_set[" << endo2block[j] << "].first[" << i << "] = " << i << endl;
-          cout << "endo2block[" << j << "] = " << 0 << endl;
-          cout.flush();
-          */
-          i++;
-          j++;
-        }
-    }
-/*  for (unsigned int j = 0; j < is_equation_linear.size() ; j++)
-     cout << "endo2block[" << j << "] = " << endo2block[j] << endl;*/
-  /*cout << "before getVariableLeadLAgByBlock\n";
-  cout.flush();*/
+    if (!is_equation_linear[it])
+      {
+        equation_reordered[i] = it;
+        variable_reordered[i] = j;
+        endo2block[j] = 0;
+        components_set[endo2block[j]].first.insert(i);
+        i++;
+        j++;
+      }
   getVariableLeadLagByBlock(dynamic_jacobian, endo2block, endo2block.size(), equation_lag_lead, variable_lag_lead, equation_reordered, variable_reordered);
   n_static = vector<unsigned int>(endo2eq.size(), 0);
   n_forward = vector<unsigned int>(endo2eq.size(), 0);
@@ -505,7 +488,7 @@ ModelTree::select_non_linear_equations_and_variables(vector<bool> is_equation_li
   n_mixed = vector<unsigned int>(endo2eq.size(), 0);
   for (unsigned int i = 0; i < endo2eq.size(); i++)
     {
-      if      (variable_lag_lead[variable_reordered[i]].first != 0 && variable_lag_lead[variable_reordered[i]].second != 0)
+      if (variable_lag_lead[variable_reordered[i]].first != 0 && variable_lag_lead[variable_reordered[i]].second != 0)
         n_mixed[i]++;
       else if (variable_lag_lead[variable_reordered[i]].first == 0 && variable_lag_lead[variable_reordered[i]].second != 0)
         n_forward[i]++;
@@ -543,10 +526,9 @@ ModelTree::computeNaturalNormalization()
         if (result.size() == 1 && result.begin()->second == 0)
           {
             //check if the endogenous variable has not been already used in an other match !
-             auto it = find(endo2eq.begin(), endo2eq.end(), result.begin()->first);
-             if (it == endo2eq.end())
-               endo2eq[result.begin()->first] = eq;
-             else
+            if (find(endo2eq.begin(), endo2eq.end(), result.begin()->first) == endo2eq.end())
+              endo2eq[result.begin()->first] = eq;
+            else
               {
                 bool_result = false;
                 break;
@@ -791,17 +773,16 @@ ModelTree::computeBlockDecompositionAndFeedbackVariablesForEachBlock(const jacob
           equations[i]->collectEndogenous(endo);
           for (const auto & it : endo)
             tmp_normalized_contemporaneous_jacobian[{ i, it.first }] = 1;
-
         }
     }
   else
     tmp_normalized_contemporaneous_jacobian = static_jacobian;
-  for (const auto &it : tmp_normalized_contemporaneous_jacobian)
-    if (reverse_equation_reordered[it.first.first] >= static_cast<int>(prologue) && reverse_equation_reordered[it.first.first] < static_cast<int>(nb_var - epilogue)
-        && reverse_variable_reordered[it.first.second] >= static_cast<int>(prologue) && reverse_variable_reordered[it.first.second] < static_cast<int>(nb_var - epilogue)
-        && it.first.first != endo2eq[it.first.second])
-      add_edge(vertex(reverse_equation_reordered[endo2eq[it.first.second]]-prologue, G2),
-               vertex(reverse_equation_reordered[it.first.first]-prologue, G2),
+  for (const auto &[key, value] : tmp_normalized_contemporaneous_jacobian)
+    if (reverse_equation_reordered[key.first] >= static_cast<int>(prologue) && reverse_equation_reordered[key.first] < static_cast<int>(nb_var - epilogue)
+        && reverse_variable_reordered[key.second] >= static_cast<int>(prologue) && reverse_variable_reordered[key.second] < static_cast<int>(nb_var - epilogue)
+        && key.first != endo2eq[key.second])
+      add_edge(vertex(reverse_equation_reordered[endo2eq[key.second]]-prologue, G2),
+               vertex(reverse_equation_reordered[key.first]-prologue, G2),
                G2);
 
   vector<int> endo2block(num_vertices(G2)), discover_time(num_vertices(G2));
@@ -867,11 +848,10 @@ ModelTree::computeBlockDecompositionAndFeedbackVariablesForEachBlock(const jacob
           add_edge(vertex(i, G2), vertex(i, G2), G2);
     }
   else
-    {
-      for (int i = 0; i < n; i++)
-        if (Equation_Type[equation_reordered[i+prologue]].first == E_SOLVE || mfs == 0)
-          add_edge(vertex(i, G2), vertex(i, G2), G2);
-    }
+    for (int i = 0; i < n; i++)
+      if (Equation_Type[equation_reordered[i+prologue]].first == E_SOLVE || mfs == 0)
+        add_edge(vertex(i, G2), vertex(i, G2), G2);
+
   //Determines the dynamic structure of each equation
   n_static = vector<unsigned int>(prologue+num+epilogue, 0);
   n_forward = vector<unsigned int>(prologue+num+epilogue, 0);
@@ -879,16 +859,15 @@ ModelTree::computeBlockDecompositionAndFeedbackVariablesForEachBlock(const jacob
   n_mixed = vector<unsigned int>(prologue+num+epilogue, 0);
 
   for (int i = 0; i < static_cast<int>(prologue); i++)
-    {
-      if      (variable_lag_lead[tmp_variable_reordered[i]].first != 0 && variable_lag_lead[tmp_variable_reordered[i]].second != 0)
-        n_mixed[i]++;
-      else if (variable_lag_lead[tmp_variable_reordered[i]].first == 0 && variable_lag_lead[tmp_variable_reordered[i]].second != 0)
-        n_forward[i]++;
-      else if (variable_lag_lead[tmp_variable_reordered[i]].first != 0 && variable_lag_lead[tmp_variable_reordered[i]].second == 0)
-        n_backward[i]++;
-      else if (variable_lag_lead[tmp_variable_reordered[i]].first == 0 && variable_lag_lead[tmp_variable_reordered[i]].second == 0)
-        n_static[i]++;
-    }
+    if (variable_lag_lead[tmp_variable_reordered[i]].first != 0 && variable_lag_lead[tmp_variable_reordered[i]].second != 0)
+      n_mixed[i]++;
+    else if (variable_lag_lead[tmp_variable_reordered[i]].first == 0 && variable_lag_lead[tmp_variable_reordered[i]].second != 0)
+      n_forward[i]++;
+    else if (variable_lag_lead[tmp_variable_reordered[i]].first != 0 && variable_lag_lead[tmp_variable_reordered[i]].second == 0)
+      n_backward[i]++;
+    else if (variable_lag_lead[tmp_variable_reordered[i]].first == 0 && variable_lag_lead[tmp_variable_reordered[i]].second == 0)
+      n_static[i]++;
+
   //For each block, the minimum set of feedback variable is computed
   // and the non-feedback variables are reordered to get
   // a sub-recursive block without feedback variables
@@ -897,7 +876,6 @@ ModelTree::computeBlockDecompositionAndFeedbackVariablesForEachBlock(const jacob
     {
       AdjacencyList_t G = extract_subgraph(G2, get<0>(components_set[i]));
       set<int> feed_back_vertices;
-      //Print(G);
       AdjacencyList_t G1 = Minimal_set_of_feedback_vertex(feed_back_vertices, G);
       auto v_index = get(boost::vertex_index, G);
       get<1>(components_set[i]) = feed_back_vertices;
@@ -907,86 +885,81 @@ ModelTree::computeBlockDecompositionAndFeedbackVariablesForEachBlock(const jacob
 
       //First we have the recursive equations conditional on feedback variables
       for (int j = 0; j < 4; j++)
-        {
-          for (int its : Reordered_Vertice)
-            {
-              bool something_done = false;
-              if      (j == 2 && variable_lag_lead[tmp_variable_reordered[its +prologue]].first != 0 && variable_lag_lead[tmp_variable_reordered[its +prologue]].second != 0)
-                {
-                  n_mixed[prologue+i]++;
-                  something_done = true;
-                }
-              else if (j == 3 && variable_lag_lead[tmp_variable_reordered[its +prologue]].first == 0 && variable_lag_lead[tmp_variable_reordered[its +prologue]].second != 0)
-                {
-                  n_forward[prologue+i]++;
-                  something_done = true;
-                }
-              else if (j == 1 && variable_lag_lead[tmp_variable_reordered[its +prologue]].first != 0 && variable_lag_lead[tmp_variable_reordered[its +prologue]].second == 0)
-                {
-                  n_backward[prologue+i]++;
-                  something_done = true;
-                }
-              else if (j == 0 && variable_lag_lead[tmp_variable_reordered[its +prologue]].first == 0 && variable_lag_lead[tmp_variable_reordered[its +prologue]].second == 0)
-                {
-                  n_static[prologue+i]++;
-                  something_done = true;
-                }
-              if (something_done)
-                {
-                  equation_reordered[order] = tmp_equation_reordered[its+prologue];
-                  variable_reordered[order] = tmp_variable_reordered[its+prologue];
-                  order++;
-                }
-            }
-        }
+        for (int its : Reordered_Vertice)
+          {
+            bool something_done = false;
+            if (j == 2 && variable_lag_lead[tmp_variable_reordered[its+prologue]].first != 0 && variable_lag_lead[tmp_variable_reordered[its+prologue]].second != 0)
+              {
+                n_mixed[prologue+i]++;
+                something_done = true;
+              }
+            else if (j == 3 && variable_lag_lead[tmp_variable_reordered[its+prologue]].first == 0 && variable_lag_lead[tmp_variable_reordered[its+prologue]].second != 0)
+              {
+                n_forward[prologue+i]++;
+                something_done = true;
+              }
+            else if (j == 1 && variable_lag_lead[tmp_variable_reordered[its+prologue]].first != 0 && variable_lag_lead[tmp_variable_reordered[its+prologue]].second == 0)
+              {
+                n_backward[prologue+i]++;
+                something_done = true;
+              }
+            else if (j == 0 && variable_lag_lead[tmp_variable_reordered[its+prologue]].first == 0 && variable_lag_lead[tmp_variable_reordered[its+prologue]].second == 0)
+              {
+                n_static[prologue+i]++;
+                something_done = true;
+              }
+            if (something_done)
+              {
+                equation_reordered[order] = tmp_equation_reordered[its+prologue];
+                variable_reordered[order] = tmp_variable_reordered[its+prologue];
+                order++;
+              }
+          }
+
       get<2>(components_set[i]) = Reordered_Vertice;
       //Second we have the equations related to the feedback variables
       for (int j = 0; j < 4; j++)
-        {
-          for (int feed_back_vertice : feed_back_vertices)
-            {
-              bool something_done = false;
-              if      (j == 2 && variable_lag_lead[tmp_variable_reordered[v_index[vertex(feed_back_vertice, G)]+prologue]].first != 0 && variable_lag_lead[tmp_variable_reordered[v_index[vertex(feed_back_vertice, G)]+prologue]].second != 0)
-                {
-                  n_mixed[prologue+i]++;
-                  something_done = true;
-                }
-              else if (j == 3 && variable_lag_lead[tmp_variable_reordered[v_index[vertex(feed_back_vertice, G)]+prologue]].first == 0 && variable_lag_lead[tmp_variable_reordered[v_index[vertex(feed_back_vertice, G)]+prologue]].second != 0)
-                {
-                  n_forward[prologue+i]++;
-                  something_done = true;
-                }
-              else if (j == 1 && variable_lag_lead[tmp_variable_reordered[v_index[vertex(feed_back_vertice, G)]+prologue]].first != 0 && variable_lag_lead[tmp_variable_reordered[v_index[vertex(feed_back_vertice, G)]+prologue]].second == 0)
-                {
-                  n_backward[prologue+i]++;
-                  something_done = true;
-                }
-              else if (j == 0 && variable_lag_lead[tmp_variable_reordered[v_index[vertex(feed_back_vertice, G)]+prologue]].first == 0 && variable_lag_lead[tmp_variable_reordered[v_index[vertex(feed_back_vertice, G)]+prologue]].second == 0)
-                {
-                  n_static[prologue+i]++;
-                  something_done = true;
-                }
-              if (something_done)
-                {
-                  equation_reordered[order] = tmp_equation_reordered[v_index[vertex(feed_back_vertice, G)]+prologue];
-                  variable_reordered[order] = tmp_variable_reordered[v_index[vertex(feed_back_vertice, G)]+prologue];
-                  order++;
-                }
-            }
-        }
+        for (int feed_back_vertice : feed_back_vertices)
+          {
+            bool something_done = false;
+            if (j == 2 && variable_lag_lead[tmp_variable_reordered[v_index[vertex(feed_back_vertice, G)]+prologue]].first != 0 && variable_lag_lead[tmp_variable_reordered[v_index[vertex(feed_back_vertice, G)]+prologue]].second != 0)
+              {
+                n_mixed[prologue+i]++;
+                something_done = true;
+              }
+            else if (j == 3 && variable_lag_lead[tmp_variable_reordered[v_index[vertex(feed_back_vertice, G)]+prologue]].first == 0 && variable_lag_lead[tmp_variable_reordered[v_index[vertex(feed_back_vertice, G)]+prologue]].second != 0)
+              {
+                n_forward[prologue+i]++;
+                something_done = true;
+              }
+            else if (j == 1 && variable_lag_lead[tmp_variable_reordered[v_index[vertex(feed_back_vertice, G)]+prologue]].first != 0 && variable_lag_lead[tmp_variable_reordered[v_index[vertex(feed_back_vertice, G)]+prologue]].second == 0)
+              {
+                n_backward[prologue+i]++;
+                something_done = true;
+              }
+            else if (j == 0 && variable_lag_lead[tmp_variable_reordered[v_index[vertex(feed_back_vertice, G)]+prologue]].first == 0 && variable_lag_lead[tmp_variable_reordered[v_index[vertex(feed_back_vertice, G)]+prologue]].second == 0)
+              {
+                n_static[prologue+i]++;
+                something_done = true;
+              }
+            if (something_done)
+              {
+                equation_reordered[order] = tmp_equation_reordered[v_index[vertex(feed_back_vertice, G)]+prologue];
+                variable_reordered[order] = tmp_variable_reordered[v_index[vertex(feed_back_vertice, G)]+prologue];
+                order++;
+              }
+          }
     }
 
   for (int i = 0; i < static_cast<int>(epilogue); i++)
-    {
-      if      (variable_lag_lead[tmp_variable_reordered[prologue+n+i]].first != 0 && variable_lag_lead[tmp_variable_reordered[prologue+n+i]].second != 0)
-        n_mixed[prologue+num+i]++;
-      else if (variable_lag_lead[tmp_variable_reordered[prologue+n+i]].first == 0 && variable_lag_lead[tmp_variable_reordered[prologue+n+i]].second != 0)
-        n_forward[prologue+num+i]++;
-      else if (variable_lag_lead[tmp_variable_reordered[prologue+n+i]].first != 0 && variable_lag_lead[tmp_variable_reordered[prologue+n+i]].second == 0)
-        n_backward[prologue+num+i]++;
-      else if (variable_lag_lead[tmp_variable_reordered[prologue+n+i]].first == 0 && variable_lag_lead[tmp_variable_reordered[prologue+n+i]].second == 0)
-        n_static[prologue+num+i]++;
-    }
+    if (variable_lag_lead[tmp_variable_reordered[prologue+n+i]].first != 0 && variable_lag_lead[tmp_variable_reordered[prologue+n+i]].second != 0)
+      n_mixed[prologue+num+i]++;
+    else if (variable_lag_lead[tmp_variable_reordered[prologue+n+i]].first == 0 && variable_lag_lead[tmp_variable_reordered[prologue+n+i]].second != 0)
+      n_forward[prologue+num+i]++;
+    else if (variable_lag_lead[tmp_variable_reordered[prologue+n+i]].first != 0 && variable_lag_lead[tmp_variable_reordered[prologue+n+i]].second == 0)
+      n_backward[prologue+num+i]++;
+    else if (variable_lag_lead[tmp_variable_reordered[prologue+n+i]].first == 0 && variable_lag_lead[tmp_variable_reordered[prologue+n+i]].second == 0)
+      n_static[prologue+num+i]++;
 
   inv_equation_reordered.resize(nb_var);
   inv_variable_reordered.resize(nb_var);
@@ -1000,9 +973,9 @@ ModelTree::computeBlockDecompositionAndFeedbackVariablesForEachBlock(const jacob
 void
 ModelTree::printBlockDecomposition(const vector<pair<int, int>> &blocks) const
 {
-  int largest_block = 0;
-  int Nb_SimulBlocks = 0;
-  int Nb_feedback_variable = 0;
+  int largest_block = 0,
+    Nb_SimulBlocks = 0,
+    Nb_feedback_variable = 0;
   unsigned int Nb_TotalBlocks = getNbBlocks();
   for (unsigned int block = 0; block < Nb_TotalBlocks; block++)
     {
@@ -1036,10 +1009,7 @@ ModelTree::reduceBlocksAndTypeDetermination(const dynamic_jacob_map_t &dynamic_j
   block_type_firstequation_size_mfs_t block_type_size_mfs;
   BlockSimulationType Simulation_Type, prev_Type = UNKNOWN;
   int eq = 0;
-  unsigned int l_n_static = 0;
-  unsigned int l_n_forward = 0;
-  unsigned int l_n_backward = 0;
-  unsigned int l_n_mixed = 0;
+  unsigned int l_n_static = 0, l_n_forward = 0, l_n_backward = 0, l_n_mixed = 0;
   for (i = 0; i < static_cast<int>(prologue+blocks.size()+epilogue); i++)
     {
       int first_count_equ = count_equ;
@@ -1062,7 +1032,7 @@ ModelTree::reduceBlocksAndTypeDetermination(const dynamic_jacob_map_t &dynamic_j
 
       Lag = Lead = 0;
       set<pair<int, int>> endo;
-      for (count_equ  = first_count_equ; count_equ  < Blck_Size+first_count_equ; count_equ++)
+      for (count_equ = first_count_equ; count_equ < Blck_Size+first_count_equ; count_equ++)
         {
           endo.clear();
           equations[equation_reordered[count_equ]]->collectEndogenous(endo);
@@ -1070,7 +1040,6 @@ ModelTree::reduceBlocksAndTypeDetermination(const dynamic_jacob_map_t &dynamic_j
             {
               int curr_variable = it.first;
               int curr_lag = it.second;
-              auto it1 = find(variable_reordered.begin()+first_count_equ, variable_reordered.begin()+(first_count_equ+Blck_Size), curr_variable);
               if (linear_decomposition)
                 {
                   if (dynamic_jacobian.find({ curr_lag, equation_reordered[count_equ], curr_variable }) != dynamic_jacobian.end())
@@ -1083,18 +1052,19 @@ ModelTree::reduceBlocksAndTypeDetermination(const dynamic_jacob_map_t &dynamic_j
                 }
               else
                 {
-                  if (it1 != variable_reordered.begin()+(first_count_equ+Blck_Size))
-                    if (dynamic_jacobian.find({ curr_lag, equation_reordered[count_equ], curr_variable }) != dynamic_jacobian.end())
-                      {
-                        if (curr_lag > Lead)
-                          Lead = curr_lag;
-                        else if (-curr_lag > Lag)
-                          Lag = -curr_lag;
-                      }
+                  if (find(variable_reordered.begin()+first_count_equ, variable_reordered.begin()+(first_count_equ+Blck_Size), curr_variable)
+                      != variable_reordered.begin()+(first_count_equ+Blck_Size)
+                      && dynamic_jacobian.find({ curr_lag, equation_reordered[count_equ], curr_variable }) != dynamic_jacobian.end())
+                    {
+                      if (curr_lag > Lead)
+                        Lead = curr_lag;
+                      else if (-curr_lag > Lag)
+                        Lag = -curr_lag;
+                    }
                 }
             }
         }
-      if ((Lag > 0) && (Lead > 0))
+      if (Lag > 0 && Lead > 0)
         {
           if (Blck_Size == 1)
             Simulation_Type = SOLVE_TWO_BOUNDARIES_SIMPLE;
@@ -1217,50 +1187,34 @@ ModelTree::BlockLinear(const blocks_derivatives_t &blocks_derivatives, const vec
       block_derivatives_equation_variable_laglead_nodeid_t derivatives_block = blocks_derivatives[block];
       int first_variable_position = getBlockFirstEquation(block);
       if (simulation_type == SOLVE_BACKWARD_COMPLETE || simulation_type == SOLVE_FORWARD_COMPLETE)
-        {
-          for (const auto &it : derivatives_block)
-            {
-              int lag = get<2>(it);
-              if (lag == 0)
-                {
-                  expr_t Id = get<3>(it);
-                  set<pair<int, int>> endogenous;
-                  Id->collectEndogenous(endogenous);
-                  if (endogenous.size() > 0)
-                    {
-                      for (int l = 0; l < block_size; l++)
-                        {
-                          if (endogenous.find({ variable_reordered[first_variable_position+l], 0 }) != endogenous.end())
-                            {
-                              blocks_linear[block] = false;
-                              goto the_end;
-                            }
-                        }
-                    }
-                }
-            }
-        }
-      else if (simulation_type == SOLVE_TWO_BOUNDARIES_COMPLETE || simulation_type == SOLVE_TWO_BOUNDARIES_SIMPLE)
-        {
-          for (const auto &it : derivatives_block)
-            {
-              int lag = get<2>(it);
-              expr_t Id = get<3>(it); //
-              set<pair<int, int>> endogenous;
-              Id->collectEndogenous(endogenous);
-              if (endogenous.size() > 0)
-                {
+        for (const auto &[ignore, ignore2, lag, d1] : derivatives_block)
+          {
+            if (lag == 0)
+              {
+                set<pair<int, int>> endogenous;
+                d1->collectEndogenous(endogenous);
+                if (endogenous.size() > 0)
                   for (int l = 0; l < block_size; l++)
-                    {
-                      if (endogenous.find({ variable_reordered[first_variable_position+l], lag }) != endogenous.end())
-                        {
-                          blocks_linear[block] = false;
-                          goto the_end;
-                        }
-                    }
-                }
-            }
-        }
+                    if (endogenous.find({ variable_reordered[first_variable_position+l], 0 }) != endogenous.end())
+                      {
+                        blocks_linear[block] = false;
+                        goto the_end;
+                      }
+              }
+          }
+      else if (simulation_type == SOLVE_TWO_BOUNDARIES_COMPLETE || simulation_type == SOLVE_TWO_BOUNDARIES_SIMPLE)
+        for (const auto &[ignore, ignore2, lag, d1] : derivatives_block)
+          {
+            set<pair<int, int>> endogenous;
+            d1->collectEndogenous(endogenous);
+            if (endogenous.size() > 0)
+              for (int l = 0; l < block_size; l++)
+                if (endogenous.find({ variable_reordered[first_variable_position+l], lag }) != endogenous.end())
+                  {
+                    blocks_linear[block] = false;
+                    goto the_end;
+                  }
+          }
     the_end:
       ;
     }
@@ -1278,9 +1232,9 @@ ModelTree::writeDerivative(ostream &output, int eq, int symb_id, int lag,
                            ExprNodeOutputType output_type,
                            const temporary_terms_t &temporary_terms) const
 {
-  auto it = derivatives[1].find({ eq, getDerivID(symb_id, lag) });
-  if (it != derivatives[1].end())
-    (it->second)->writeOutput(output, output_type, temporary_terms, {});
+  if (auto it = derivatives[1].find({ eq, getDerivID(symb_id, lag) });
+      it != derivatives[1].end())
+    it->second->writeOutput(output, output_type, temporary_terms, {});
   else
     output << 0;
 }
@@ -1434,7 +1388,7 @@ ModelTree::writeTemporaryTerms(const temporary_terms_t &tt,
 {
   for (auto it : tt)
     {
-      if (dynamic_cast<AbstractExternalFunctionNode *>(it) != nullptr)
+      if (dynamic_cast<AbstractExternalFunctionNode *>(it))
         it->writeExternalFunctionOutput(output, output_type, temp_term_union, tt_idxs, tef_terms);
 
       if (isJuliaOutput(output_type))
@@ -1465,7 +1419,7 @@ ModelTree::writeJsonTemporaryTerms(const temporary_terms_t &tt,
   output << R"("external_functions_temporary_terms_)" << concat << R"(": [)";
   for (auto it : tt)
     {
-      if (dynamic_cast<AbstractExternalFunctionNode *>(it) != nullptr)
+      if (dynamic_cast<AbstractExternalFunctionNode *>(it))
         {
           if (wrote_term)
             output << ", ";
@@ -1513,7 +1467,6 @@ ModelTree::fixNestedParenthesis(ostringstream &output, map<string, string> &tmp_
   int matching_paren = 0;
   bool hit_limit = false;
   int i1 = 0;
-  map<string, string>::iterator it;
   for (size_t i = 0; i < str.length(); i++)
     {
       if (str.at(i) == '(')
@@ -1543,8 +1496,7 @@ ModelTree::fixNestedParenthesis(ostringstream &output, map<string, string> &tmp_
               message_printed = true;
             }
           string str1 = str.substr(first_open_paren, matching_paren - first_open_paren + 1);
-          string repstr = "";
-          string varname;
+          string repstr, varname;
           while (testNestedParenthesis(str1))
             {
               size_t open_paren_idx  = string::npos;
@@ -1555,24 +1507,24 @@ ModelTree::fixNestedParenthesis(ostringstream &output, map<string, string> &tmp_
                   if (str1.at(j) == '(')
                     {
                       // don't match, e.g. y(1)
-                      size_t idx = str1.find_last_of("*/-+", j - 1);
-                      if (j == 0 || (idx != string::npos && idx == j - 1))
+                      if (size_t idx = str1.find_last_of("*/-+", j - 1);
+                          j == 0 || (idx != string::npos && idx == j - 1))
                         open_paren_idx = j;
                       last_open_paren = j;
                     }
                   else if (str1.at(j) == ')')
                     {
                       // don't match, e.g. y(1)
-                      size_t idx = str1.find_last_not_of("0123456789", j - 1);
-                      if (idx != string::npos && idx != last_open_paren)
+                      if (size_t idx = str1.find_last_not_of("0123456789", j - 1);
+                          idx != string::npos && idx != last_open_paren)
                         match_paren_idx = j;
                     }
 
                   if (open_paren_idx != string::npos && match_paren_idx != string::npos)
                     {
                       string val = str1.substr(open_paren_idx, match_paren_idx - open_paren_idx + 1);
-                      it = tmp_paren_vars.find(val);
-                      if (it == tmp_paren_vars.end())
+                      if (auto it = tmp_paren_vars.find(val);
+                          it == tmp_paren_vars.end())
                         {
                           ostringstream ptvstr;
                           ptvstr << i1++;
@@ -1587,8 +1539,8 @@ ModelTree::fixNestedParenthesis(ostringstream &output, map<string, string> &tmp_
                     }
                 }
             }
-          it = tmp_paren_vars.find(str1);
-          if (it == tmp_paren_vars.end())
+          if (auto it = tmp_paren_vars.find(str1);
+              it == tmp_paren_vars.end())
             {
               ostringstream ptvstr;
               ptvstr << i1++;
@@ -1633,7 +1585,7 @@ ModelTree::compileTemporaryTerms(ostream &code_file, unsigned int &instruction_n
   deriv_node_temp_terms_t tef_terms;
   for (auto it : tt)
     {
-      if (dynamic_cast<AbstractExternalFunctionNode *>(it) != nullptr)
+      if (dynamic_cast<AbstractExternalFunctionNode *>(it))
         {
           it->compileExternalFunctionOutput(code_file, instruction_number, false, tt2, map_idx, dynamic, steady_dynamic, tef_terms);
         }
@@ -1684,7 +1636,7 @@ ModelTree::writeJsonModelLocalVariables(ostream &output, deriv_node_temp_terms_t
         vector<string> efout;
         expr_t value = local_variables_table.find(id)->second;
         value->writeJsonExternalFunctionOutput(efout, tt, tef_terms);
-        for (vector<string>::const_iterator it1 = efout.begin(); it1 != efout.end(); it1++)
+        for (auto it1 = efout.begin(); it1 != efout.end(); ++it1)
           {
             if (it1 != efout.begin())
               output << ", ";
@@ -1827,12 +1779,12 @@ ModelTree::Write_Inf_To_Bin_File(const string &filename,
       exit(EXIT_FAILURE);
     }
   u_count_int = 0;
-  for (const auto & first_derivative : derivatives[1])
+  for (const auto & [indices, d1] : derivatives[1])
     {
-      int deriv_id = first_derivative.first[1];
+      int deriv_id = indices[1];
       if (getTypeByDerivID(deriv_id) == SymbolType::endogenous)
         {
-          int eq = first_derivative.first[0];
+          int eq = indices[0];
           int symb = getSymbIDByDerivID(deriv_id);
           int var = symbol_table.getTypeSpecificID(symb);
           int lag = getLagByDerivID(deriv_id);
@@ -1855,7 +1807,7 @@ ModelTree::Write_Inf_To_Bin_File(const string &filename,
 }
 
 void
-ModelTree::writeLatexModelFile(const string &mod_basename, const string &latex_basename, ExprNodeOutputType output_type, const bool write_equation_tags) const
+ModelTree::writeLatexModelFile(const string &mod_basename, const string &latex_basename, ExprNodeOutputType output_type, bool write_equation_tags) const
 {
   filesystem::create_directories(mod_basename + "/latex");
 
@@ -1902,18 +1854,18 @@ ModelTree::writeLatexModelFile(const string &mod_basename, const string &latex_b
       if (write_equation_tags)
         {
           bool wrote_eq_tag = false;
-          for (const auto & equation_tag : equation_tags)
-            if (equation_tag.first == eq)
+          for (const auto & [tagged_eq, tag_pair] : equation_tags)
+            if (tagged_eq == eq)
               {
                 if (!wrote_eq_tag)
                   content_output << R"(\noindent[)";
                 else
                   content_output << ", ";
 
-                content_output << equation_tag.second.first;
+                content_output << tag_pair.first;
 
-                if (!(equation_tag.second.second.empty()))
-                  content_output << "= `" << equation_tag.second.second << "'";
+                if (!(tag_pair.second.empty()))
+                  content_output << "= `" << tag_pair.second << "'";
 
                 wrote_eq_tag = true;
               }
@@ -1938,8 +1890,8 @@ ModelTree::writeLatexModelFile(const string &mod_basename, const string &latex_b
 void
 ModelTree::addEquation(expr_t eq, int lineno)
 {
-  auto *beq = dynamic_cast<BinaryOpNode *>(eq);
-  assert(beq != nullptr && beq->op_code == BinaryOpcode::equal);
+  auto beq = dynamic_cast<BinaryOpNode *>(eq);
+  assert(beq && beq->op_code == BinaryOpcode::equal);
 
   equations.push_back(beq);
   equations_lineno.push_back(lineno);
@@ -1961,7 +1913,7 @@ ModelTree::includeExcludeEquations(set<pair<string, string>> &eqs, bool exclude_
     if (equation_tags_xref.find(it) != equation_tags_xref.end())
       {
         auto range = equation_tags_xref.equal_range(it);
-        for_each ( range.first, range.second, [&tag_eqns](auto & x){ tag_eqns.insert(x.second); } );
+        for_each (range.first, range.second, [&tag_eqns](auto & x){ tag_eqns.insert(x.second); });
         eqs.erase(it);
       }
   if (tag_eqns.empty())
@@ -1983,11 +1935,11 @@ ModelTree::includeExcludeEquations(set<pair<string, string>> &eqs, bool exclude_
     if (eqns.find(i) != eqns.end())
       {
         bool found = false;
-        for (const auto & it : equation_tags)
-          if (it.first == static_cast<int>(i) && it.second.first == "endogenous")
+        for (const auto & [tagged_eq, tag_pair] : equation_tags)
+          if (tagged_eq == static_cast<int>(i) && tag_pair.first == "endogenous")
             {
               found = true;
-              excluded_vars.push_back(symbol_table.getID(it.second.second));
+              excluded_vars.push_back(symbol_table.getID(tag_pair.second));
               break;
             }
         if (!found)
@@ -2081,8 +2033,8 @@ ModelTree::addEquation(expr_t eq, int lineno, const vector<pair<string, string>>
 void
 ModelTree::addAuxEquation(expr_t eq)
 {
-  auto *beq = dynamic_cast<BinaryOpNode *>(eq);
-  assert(beq != nullptr && beq->op_code == BinaryOpcode::equal);
+  auto beq = dynamic_cast<BinaryOpNode *>(eq);
+  assert(beq && beq->op_code == BinaryOpcode::equal);
 
   aux_equations.push_back(beq);
 }
@@ -2167,33 +2119,33 @@ ModelTree::computeParamsDerivatives(int paramsDerivsOrder)
         }
 
       for (int endoOrd = 1; endoOrd < static_cast<int>(derivatives.size()); endoOrd++)
-        for (const auto &it : derivatives[endoOrd])
+        for (const auto &[indices, dprev] : derivatives[endoOrd])
           {
-            expr_t d = it.second->getDerivative(param);
+            expr_t d = dprev->getDerivative(param);
             if (d == Zero)
               continue;
-            vector<int> indices{it.first};
-            indices.push_back(param);
-            params_derivatives[{ endoOrd, 1 }][indices] = d;
+            vector<int> new_indices = indices;
+            new_indices.push_back(param);
+            params_derivatives[{ endoOrd, 1 }][new_indices] = d;
           }
     }
 
   // Higher-order derivatives w.r.t. parameters
   for (int endoOrd = 0; endoOrd < static_cast<int>(derivatives.size()); endoOrd++)
     for (int paramOrd = 2; paramOrd <= paramsDerivsOrder; paramOrd++)
-      for (const auto &it : params_derivatives[{ endoOrd, paramOrd-1 }])
+      for (const auto &[indices, dprev] : params_derivatives[{ endoOrd, paramOrd-1 }])
         for (int param : deriv_id_set)
           {
-            if (it.first.back() > param)
+            if (indices.back() > param)
               continue;
 
-            expr_t d = it.second->getDerivative(param);
+            expr_t d = dprev->getDerivative(param);
             if (d == Zero)
               continue;
-            vector<int> indices{it.first};
-            indices.push_back(param);
+            vector<int> new_indices = indices;
+            new_indices.push_back(param);
             // At this point, indices of both endogenous and parameters are sorted in non-decreasing order
-            params_derivatives[{ endoOrd, paramOrd }][indices] = d;
+            params_derivatives[{ endoOrd, paramOrd }][new_indices] = d;
           }
 }
 
@@ -2205,33 +2157,28 @@ ModelTree::computeParamsDerivativesTemporaryTerms()
   /* The temp terms should be constructed in the same order as the for loops in
      {Static,Dynamic}Model::write{Json,}ParamsDerivativesFile() */
   params_derivs_temporary_terms.clear();
-  for (const auto &it : params_derivatives)
-    for (const auto &it2 : it.second)
-      it2.second->computeTemporaryTerms(it.first,
-                                        params_derivs_temporary_terms,
-                                        reference_count,
-                                        true);
+  for (const auto &[order, derivs] : params_derivatives)
+    for (const auto &[indices, d] : derivs)
+      d->computeTemporaryTerms(order, params_derivs_temporary_terms,
+                               reference_count, true);
 
   int idx = 0;
-  for (auto &it : temporary_terms_mlv)
-    params_derivs_temporary_terms_idxs[it.first] = idx++;
-  for (const auto &it : params_derivs_temporary_terms)
-    for (const auto &tt : it.second)
+  for (auto &[mlv, value] : temporary_terms_mlv)
+    params_derivs_temporary_terms_idxs[mlv] = idx++;
+  for (const auto &[order, tts] : params_derivs_temporary_terms)
+    for (const auto &tt : tts)
       params_derivs_temporary_terms_idxs[tt] = idx++;
 }
 
 bool
 ModelTree::isNonstationary(int symb_id) const
 {
-  return (nonstationary_symbols_map.find(symb_id)
-          != nonstationary_symbols_map.end());
+  return nonstationary_symbols_map.find(symb_id) != nonstationary_symbols_map.end();
 }
 
 void
 ModelTree::writeJsonModelEquations(ostream &output, bool residuals) const
 {
-  vector<pair<string, string>> eqtags;
-  temporary_terms_t tt_empty;
   if (residuals)
     output << endl << R"("residuals":[)" << endl;
   else
@@ -2273,25 +2220,23 @@ ModelTree::writeJsonModelEquations(ostream &output, bool residuals) const
       else
         {
           output << R"({"lhs": ")";
-          lhs->writeJsonOutput(output, tt_empty, {});
+          lhs->writeJsonOutput(output, {}, {});
           output << R"(", "rhs": ")";
-          rhs->writeJsonOutput(output, tt_empty, {});
+          rhs->writeJsonOutput(output, {}, {});
           output << R"(")"
                  << R"(, "line": )" << equations_lineno[eq];
 
-          for (const auto & equation_tag : equation_tags)
-            if (equation_tag.first == eq)
-              eqtags.push_back(equation_tag.second);
-
-          if (!eqtags.empty())
+          if (auto eqtags = getEquationTags(eq);
+              !eqtags.empty())
             {
               output << R"(, "tags": {)";
               int i = 0;
-              for (vector<pair<string, string>>::const_iterator it = eqtags.begin(); it != eqtags.end(); it++, i++)
+              for (const auto &[name, value] : eqtags)
                 {
                   if (i != 0)
                     output << ", ";
-                  output << R"(")" << it->first << R"(": ")" << it->second << R"(")";
+                  output << R"(")" << name << R"(": ")" << value << R"(")";
+                  i++;
                 }
               output << "}";
               eqtags.clear();
@@ -2370,7 +2315,7 @@ ModelTree::compileDll(const string &basename, const string &static_or_dynamic, c
           // Windows
           flags << " -static-libgcc -static-libstdc++ -shared";
           // Put the MinGW environment shipped with Dynare in the path
-          filesystem::path mingwpath = dynareroot / (string{"mingw"} + (mexext == "mexw32" ? "32" : "64")) / "bin";
+          auto mingwpath = dynareroot / (string{"mingw"} + (mexext == "mexw32" ? "32" : "64")) / "bin";
           string newpath = "PATH=" + mingwpath.string() + ';' + string{getenv("PATH")};
           if (putenv(const_cast<char *>(newpath.c_str())) != 0)
             {
@@ -2490,11 +2435,9 @@ ModelTree::reorderAuxiliaryEquations()
       set<int> endos;
       aux_equations[i]->collectVariables(SymbolType::endogenous, endos);
       for (int endo : endos)
-        {
-          auto it = auxEndoToEq.find(endo);
-          if (it != auxEndoToEq.end() && it->second != i)
-            add_edge(i, it->second, g);
-        }
+        if (auto it = auxEndoToEq.find(endo);
+            it != auxEndoToEq.end() && it->second != i)
+          add_edge(i, it->second, g);
     }
 
   // Topological sort of the graph
diff --git a/src/ModelTree.hh b/src/ModelTree.hh
index e9b9d4a9055a5d0aa669260781f129e4f20691cf..3b3426bb9114886bb4efbb7e542617217860095a 100644
--- a/src/ModelTree.hh
+++ b/src/ModelTree.hh
@@ -65,12 +65,8 @@ class ModelTree : public DataTree
   friend class DynamicModel;
   friend class StaticModel;
 public:
-  // The following 5 variables are set via the `compiler` command
-  string user_set_add_flags;
-  string user_set_subst_flags;
-  string user_set_add_libs;
-  string user_set_subst_libs;
-  string user_set_compiler;
+  // Set via the `compiler` command
+  string user_set_add_flags, user_set_subst_flags, user_set_add_libs, user_set_subst_libs, user_set_compiler;
 protected:
   /*
    * ************** BEGIN **************
@@ -205,7 +201,7 @@ protected:
   void compileModelEquations(ostream &code_file, unsigned int &instruction_number, const temporary_terms_t &tt, const map_idx_t &map_idx, bool dynamic, bool steady_dynamic) const;
 
   //! Writes LaTeX model file
-  void writeLatexModelFile(const string &mod_basename, const string &latex_basename, ExprNodeOutputType output_type, const bool write_equation_tags) const;
+  void writeLatexModelFile(const string &mod_basename, const string &latex_basename, ExprNodeOutputType output_type, bool write_equation_tags) const;
 
   //! Sparse matrix of double to store the values of the Jacobian
   /*! First index is equation number, second index is endogenous type specific ID */
@@ -242,7 +238,7 @@ protected:
   //! Try to find a natural normalization if all equations are matched to an endogenous variable on the LHS
   bool computeNaturalNormalization();
   //! Try to normalized each unnormalized equation (matched endogenous variable only on the LHS)
-  void computeNormalizedEquations(multimap<int, int> &endo2eqs) const;
+  multimap<int, int> computeNormalizedEquations() const;
   //! Evaluate the jacobian and suppress all the elements below the cutoff
   void evaluateAndReduceJacobian(const eval_context_t &eval_context, jacob_map_t &contemporaneous_jacobian, jacob_map_t &static_jacobian, dynamic_jacob_map_t &dynamic_jacobian, double cutoff, bool verbose);
   //! Select and reorder the non linear equations of the model
@@ -393,74 +389,60 @@ public:
     return r;
   }
 
-  inline static std::string
+  inline static string
   c_Equation_Type(int type)
   {
-    char c_Equation_Type[4][13] =
+    vector<string> c_Equation_Type =
       {
         "E_UNKNOWN   ",
         "E_EVALUATE  ",
         "E_EVALUATE_S",
         "E_SOLVE     "
       };
-    return (c_Equation_Type[type]);
+    return c_Equation_Type[type];
   };
 
-  inline static std::string
+  inline static string
   BlockType0(BlockType type)
   {
     switch (type)
       {
       case SIMULTANS:
-        return ("SIMULTANEOUS TIME SEPARABLE  ");
-        break;
+        return "SIMULTANEOUS TIME SEPARABLE  ";
       case PROLOGUE:
-        return ("PROLOGUE                     ");
-        break;
+        return "PROLOGUE                     ";
       case EPILOGUE:
-        return ("EPILOGUE                     ");
-        break;
+        return "EPILOGUE                     ";
       case SIMULTAN:
-        return ("SIMULTANEOUS TIME UNSEPARABLE");
-        break;
+        return "SIMULTANEOUS TIME UNSEPARABLE";
       default:
-        return ("UNKNOWN                      ");
-        break;
+        return "UNKNOWN                      ";
       }
   };
 
-  inline static std::string
+  inline static string
   BlockSim(int type)
   {
     switch (type)
       {
       case EVALUATE_FORWARD:
-        return ("EVALUATE FORWARD             ");
-        break;
+        return "EVALUATE FORWARD             ";
       case EVALUATE_BACKWARD:
-        return ("EVALUATE BACKWARD            ");
-        break;
+        return "EVALUATE BACKWARD            ";
       case SOLVE_FORWARD_SIMPLE:
-        return ("SOLVE FORWARD SIMPLE         ");
-        break;
+        return "SOLVE FORWARD SIMPLE         ";
       case SOLVE_BACKWARD_SIMPLE:
-        return ("SOLVE BACKWARD SIMPLE        ");
-        break;
+        return "SOLVE BACKWARD SIMPLE        ";
       case SOLVE_TWO_BOUNDARIES_SIMPLE:
-        return ("SOLVE TWO BOUNDARIES SIMPLE  ");
-        break;
+        return "SOLVE TWO BOUNDARIES SIMPLE  ";
       case SOLVE_FORWARD_COMPLETE:
-        return ("SOLVE FORWARD COMPLETE       ");
-        break;
+        return "SOLVE FORWARD COMPLETE       ";
       case SOLVE_BACKWARD_COMPLETE:
-        return ("SOLVE BACKWARD COMPLETE      ");
-        break;
+        return "SOLVE BACKWARD COMPLETE      ";
       case SOLVE_TWO_BOUNDARIES_COMPLETE:
-        return ("SOLVE TWO BOUNDARIES COMPLETE");
-        break;
+        return "SOLVE TWO BOUNDARIES COMPLETE";
       default:
-        return ("UNKNOWN                      ");
-        break;
+        return "UNKNOWN                      ";
       }
   };
 };
diff --git a/src/NumericalConstants.cc b/src/NumericalConstants.cc
index d536c10c164fc9eedf66666aa91035a0ca316d48..108fc6b30d9c8770edf5b1d71e30513179ac4626 100644
--- a/src/NumericalConstants.cc
+++ b/src/NumericalConstants.cc
@@ -1,5 +1,5 @@
 /*
- * Copyright © 2003-2012 Dynare Team
+ * Copyright © 2003-2019 Dynare Team
  *
  * This file is part of Dynare.
  *
@@ -26,9 +26,8 @@
 int
 NumericalConstants::AddNonNegativeConstant(const string &iConst)
 {
-  map<string, int>::const_iterator iter = numConstantsIndex.find(iConst);
-
-  if (iter != numConstantsIndex.end())
+  if (auto iter = numConstantsIndex.find(iConst);
+      iter != numConstantsIndex.end())
     return iter->second;
 
   auto id = static_cast<int>(mNumericalConstants.size());
diff --git a/src/NumericalInitialization.cc b/src/NumericalInitialization.cc
index 11f7de1e7ad2618ce7e0c213af980e7ba2bfd3f4..a24b1ebdfbe91b700e3fde92b30e88143f9b6d12 100644
--- a/src/NumericalInitialization.cc
+++ b/src/NumericalInitialization.cc
@@ -59,9 +59,6 @@ InitParamStatement::writeJuliaOutput(ostream &output, const string &basename)
   output << "model_.params[ " << id << " ] = ";
   param_value->writeOutput(output);
   output << endl;
-  // Do we really need this?
-  // if (!minimal_workspace)
-  //   output << symbol_table.getName(symb_id) << " = model_.params[ " << id << " ]" << endl;
 }
 
 void
@@ -87,7 +84,7 @@ InitParamStatement::fillEvalContext(eval_context_t &eval_context) const
 
 InitOrEndValStatement::InitOrEndValStatement(init_values_t init_values_arg,
                                              const SymbolTable &symbol_table_arg,
-                                             const bool &all_values_required_arg) :
+                                             bool all_values_required_arg) :
   init_values{move(init_values_arg)},
   symbol_table{symbol_table_arg},
   all_values_required{all_values_required_arg}
@@ -127,13 +124,11 @@ InitOrEndValStatement::getUninitializedVariables(SymbolType type)
       exit(EXIT_FAILURE);
     }
 
-  set<int>::iterator sit;
   for (const auto & init_value : init_values)
-    {
-      sit = unused.find(init_value.first);
-      if (sit != unused.end())
-        unused.erase(sit);
-    }
+    if (auto sit = unused.find(init_value.first);
+        sit != unused.end())
+      unused.erase(sit);
+
   return unused;
 }
 
@@ -190,7 +185,7 @@ InitOrEndValStatement::writeJsonInitValues(ostream &output) const
 
 InitValStatement::InitValStatement(const init_values_t &init_values_arg,
                                    const SymbolTable &symbol_table_arg,
-                                   const bool &all_values_required_arg) :
+                                   bool all_values_required_arg) :
   InitOrEndValStatement{init_values_arg, symbol_table_arg, all_values_required_arg}
 {
 }
@@ -254,7 +249,7 @@ InitValStatement::writeOutputPostInit(ostream &output) const
 
 EndValStatement::EndValStatement(const init_values_t &init_values_arg,
                                  const SymbolTable &symbol_table_arg,
-                                 const bool &all_values_required_arg) :
+                                 bool all_values_required_arg) :
   InitOrEndValStatement{init_values_arg, symbol_table_arg, all_values_required_arg}
 {
 }
@@ -308,7 +303,7 @@ EndValStatement::writeJsonOutput(ostream &output) const
 
 HistValStatement::HistValStatement(hist_values_t hist_values_arg,
                                    const SymbolTable &symbol_table_arg,
-                                   const bool &all_values_required_arg) :
+                                   bool all_values_required_arg) :
   hist_values{move(hist_values_arg)},
   symbol_table{symbol_table_arg},
   all_values_required{all_values_required_arg}
@@ -325,12 +320,12 @@ HistValStatement::checkPass(ModFileStructure &mod_file_struct, WarningConsolidat
 
       for (const auto & hist_value : hist_values)
         {
-          auto sit = unused_endo.find(hist_value.first.first);
-          if (sit != unused_endo.end())
+          if (auto sit = unused_endo.find(hist_value.first.first);
+              sit != unused_endo.end())
             unused_endo.erase(sit);
 
-          sit = unused_exo.find(hist_value.first.first);
-          if (sit != unused_exo.end())
+          if (auto sit = unused_exo.find(hist_value.first.first);
+              sit != unused_exo.end())
             unused_exo.erase(sit);
         }
 
@@ -399,7 +394,7 @@ HistValStatement::writeJsonOutput(ostream &output) const
 {
   output << R"({"statementName": "histval", "vals": [)";
   for (auto it = hist_values.begin();
-       it != hist_values.end(); it++)
+       it != hist_values.end(); ++it)
     {
       if (it != hist_values.begin())
         output << ", ";
@@ -569,9 +564,9 @@ LoadParamsAndSteadyStateStatement::LoadParamsAndSteadyStateStatement(const strin
 void
 LoadParamsAndSteadyStateStatement::writeOutput(ostream &output, const string &basename, bool minimal_workspace) const
 {
-  for (const auto & it : content)
+  for (const auto &[id, value] : content)
     {
-      switch (symbol_table.getType(it.first))
+      switch (symbol_table.getType(id))
         {
         case SymbolType::parameter:
           output << "M_.params";
@@ -586,12 +581,12 @@ LoadParamsAndSteadyStateStatement::writeOutput(ostream &output, const string &ba
           output << "oo_.exo_det_steady_state";
           break;
         default:
-          cerr << "ERROR: Unsupported variable type for " << symbol_table.getName(it.first) << " in load_params_and_steady_state" << endl;
+          cerr << "ERROR: Unsupported variable type for " << symbol_table.getName(id) << " in load_params_and_steady_state" << endl;
           exit(EXIT_FAILURE);
         }
 
-      int tsid = symbol_table.getTypeSpecificID(it.first) + 1;
-      output << "(" << tsid << ") = " << it.second << ";" << endl;
+      int tsid = symbol_table.getTypeSpecificID(id) + 1;
+      output << "(" << tsid << ") = " << value << ";" << endl;
     }
 }
 
@@ -600,8 +595,7 @@ LoadParamsAndSteadyStateStatement::writeJsonOutput(ostream &output) const
 {
   output << R"({"statementName": "load_params_and_steady_state")"
          << R"("values": [)";
-  for (auto it = content.begin();
-       it != content.end(); it++)
+  for (auto it = content.begin(); it != content.end(); ++it)
     {
       if (it != content.begin())
         output << ", ";
@@ -615,9 +609,9 @@ LoadParamsAndSteadyStateStatement::writeJsonOutput(ostream &output) const
 void
 LoadParamsAndSteadyStateStatement::fillEvalContext(eval_context_t &eval_context) const
 {
-  for (const auto & it : content)
+  for (const auto & [id, value] : content)
     /* We use strtod() instead of stod() because we want underflows and
        overflows to respectively yield 0 and ±Inf. See also the comment in
        NumericalConstants.cc */
-    eval_context[it.first] = strtod(it.second.c_str(), nullptr);
+    eval_context[id] = strtod(value.c_str(), nullptr);
 }
diff --git a/src/NumericalInitialization.hh b/src/NumericalInitialization.hh
index 2704088bf8a2f106afefdf1fdc944900b6fd47f4..93b24f9d9040a2d0ac56037999099a9139daf8be 100644
--- a/src/NumericalInitialization.hh
+++ b/src/NumericalInitialization.hh
@@ -1,5 +1,5 @@
 /*
- * Copyright © 2003-2017 Dynare Team
+ * Copyright © 2003-2019 Dynare Team
  *
  * This file is part of Dynare.
  *
@@ -62,7 +62,7 @@ protected:
 public:
   InitOrEndValStatement(init_values_t init_values_arg,
                         const SymbolTable &symbol_table_arg,
-                        const bool &all_values_required_arg);
+                        bool all_values_required_arg);
   //! Return set of unused variables by type
   set<int> getUninitializedVariables(SymbolType type);
   //! Fill eval context with variables values
@@ -77,7 +77,7 @@ class InitValStatement : public InitOrEndValStatement
 public:
   InitValStatement(const init_values_t &init_values_arg,
                    const SymbolTable &symbol_table_arg,
-                   const bool &all_values_required_arg);
+                   bool all_values_required_arg);
   void checkPass(ModFileStructure &mod_file_struct, WarningConsolidation &warnings) override;
   void writeOutput(ostream &output, const string &basename, bool minimal_workspace) const override;
   void writeJsonOutput(ostream &output) const override;
@@ -90,7 +90,7 @@ class EndValStatement : public InitOrEndValStatement
 public:
   EndValStatement(const init_values_t &init_values_arg,
                   const SymbolTable &symbol_table_arg,
-                  const bool &all_values_required_arg);
+                  bool all_values_required_arg);
   //! Workaround for trac ticket #35
   void checkPass(ModFileStructure &mod_file_struct, WarningConsolidation &warnings) override;
   void writeOutput(ostream &output, const string &basename, bool minimal_workspace) const override;
@@ -113,7 +113,7 @@ private:
 public:
   HistValStatement(hist_values_t hist_values_arg,
                    const SymbolTable &symbol_table_arg,
-                   const bool &all_values_required_arg);
+                   bool all_values_required_arg);
   //! Workaround for trac ticket #157
   void checkPass(ModFileStructure &mod_file_struct, WarningConsolidation &warnings) override;
   void writeOutput(ostream &output, const string &basename, bool minimal_workspace) const override;
diff --git a/src/ParsingDriver.cc b/src/ParsingDriver.cc
index a7cd7d15252f3a7accd21a541e165019d37c3143..3c20bbbc8b49b10ea027cc516ca12f23f592cb93 100644
--- a/src/ParsingDriver.cc
+++ b/src/ParsingDriver.cc
@@ -36,7 +36,7 @@ ParsingDriver::symbol_exists_and_is_not_modfile_local_or_external_function(const
 
   SymbolType type = mod_file->symbol_table.getType(s);
 
-  return (type != SymbolType::modFileLocalVariable && type != SymbolType::externalFunction);
+  return type != SymbolType::modFileLocalVariable && type != SymbolType::externalFunction;
 }
 
 void
@@ -355,7 +355,7 @@ ParsingDriver::declare_or_change_type(SymbolType new_type, const string &name)
         if (it->first == name)
           it = undeclared_model_variable_errors.erase(it);
         else
-          it++;
+          ++it;
     }
   catch (SymbolTable::UnknownSymbolNameException &e)
     {
@@ -396,10 +396,10 @@ ParsingDriver::add_model_variable(int symb_id, int lag)
   if (type == SymbolType::modelLocalVariable && lag != 0)
     error("Model local variable " + mod_file->symbol_table.getName(symb_id) + " cannot be given a lead or a lag.");
 
-  if (dynamic_cast<StaticModel *>(model_tree) != nullptr && lag != 0)
+  if (dynamic_cast<StaticModel *>(model_tree) && lag != 0)
     error("Leads and lags on variables are forbidden in 'planner_objective'.");
 
-  if (dynamic_cast<StaticModel *>(model_tree) != nullptr && type == SymbolType::modelLocalVariable)
+  if (dynamic_cast<StaticModel *>(model_tree) && type == SymbolType::modelLocalVariable)
     error("Model local variable " + mod_file->symbol_table.getName(symb_id) + " cannot be used in 'planner_objective'.");
 
   // It makes sense to allow a lead/lag on parameters: during steady state calibration, endogenous and parameters can be swapped
@@ -502,13 +502,12 @@ void
 ParsingDriver::add_VAR_exclusion_restriction(const string &lagstr)
 {
   int lag = stoi(lagstr);
-  auto it = exclusion_restrictions.find(lag);
-  if (it == exclusion_restrictions.end())
+  if (auto it = exclusion_restrictions.find(lag);
+      it == exclusion_restrictions.end())
     exclusion_restrictions[lag] = exclusion_restriction;
   else
-    for (map<int, SymbolList>::const_iterator it1 = exclusion_restriction.begin();
-         it1 != exclusion_restriction.end(); it1++)
-      it->second[it1->first] = it1->second;
+    for (auto & it1 : exclusion_restriction)
+      it->second[it1.first] = it1.second;
 
   exclusion_restriction.clear();
 }
@@ -771,9 +770,8 @@ ParsingDriver::differentiate_forward_vars_some()
 {
   mod_file->differentiate_forward_vars = true;
   mod_file->differentiate_forward_vars_subset = symbol_list.get_symbols();
-  for (vector<string>::const_iterator it = mod_file->differentiate_forward_vars_subset.begin();
-       it != mod_file->differentiate_forward_vars_subset.end(); ++it)
-    check_symbol_is_endogenous(*it);
+  for (auto & it : mod_file->differentiate_forward_vars_subset)
+    check_symbol_is_endogenous(it);
   symbol_list.clear();
 }
 
@@ -894,23 +892,21 @@ ParsingDriver::end_model()
 {
   bool exit_after_write = false;
   if (model_errors.size() > 0)
-    for (vector<pair<string, string>>::const_iterator it = model_errors.begin();
-         it != model_errors.end(); it++)
+    for (auto & it : model_errors)
       {
-        if (it->first == "")
+        if (it.first.empty())
           exit_after_write = true;
-        cerr << it->second;
+        cerr << it.second;
       }
 
   if (undeclared_model_variable_errors.size() > 0)
-    for (vector<pair<string, string>>::const_iterator it = undeclared_model_variable_errors.begin();
-         it != undeclared_model_variable_errors.end(); it++)
+    for (auto & it : undeclared_model_variable_errors)
       if (nostrict)
-        warning(it->second);
+        warning(it.second);
       else
         {
           exit_after_write = true;
-          cerr << it->second << endl;
+          cerr << it.second << endl;
         }
 
   if (exit_after_write)
@@ -1147,7 +1143,6 @@ ParsingDriver::combine_lag_and_restriction(const string &lag)
         new_restriction.value = data_tree->One;
         svar_ident_restrictions.push_back(new_restriction);
       }
-  //    svar_ident_exclusion_values[make_pair(current_lag, it->first)] = it->second;
 
   svar_upper_cholesky = false;
   svar_lower_cholesky = false;
@@ -1286,7 +1281,7 @@ ParsingDriver::add_restriction_element(expr_t value, const string &variable, con
 void
 ParsingDriver::check_restriction_expression_constant(expr_t value)
 {
-  if (value->eval(eval_context_t()) != 0)
+  if (value->eval({}) != 0)
     error("SVAR_INDENTIFICATION restrictions must be homogenous");
 }
 
@@ -1412,19 +1407,17 @@ ParsingDriver::option_symbol_list(string name_option)
   if (name_option.compare("irf_shocks") == 0)
     {
       vector<string> shocks = symbol_list.get_symbols();
-      for (vector<string>::const_iterator it = shocks.begin();
-           it != shocks.end(); it++)
-        if (mod_file->symbol_table.getType(*it) != SymbolType::exogenous)
-          error("Variables passed to irf_shocks must be exogenous. Caused by: " + *it);
+      for (auto & shock : shocks)
+        if (mod_file->symbol_table.getType(shock) != SymbolType::exogenous)
+          error("Variables passed to irf_shocks must be exogenous. Caused by: " + shock);
     }
 
   if (name_option.compare("ms.parameters") == 0)
     {
       vector<string> parameters = symbol_list.get_symbols();
-      for (vector<string>::const_iterator it = parameters.begin();
-           it != parameters.end(); it++)
-        if (mod_file->symbol_table.getType(*it) != SymbolType::parameter)
-          error("Variables passed to the parameters option of the markov_switching statement must be parameters. Caused by: " + *it);
+      for (auto & it : parameters)
+        if (mod_file->symbol_table.getType(it) != SymbolType::parameter)
+          error("Variables passed to the parameters option of the markov_switching statement must be parameters. Caused by: " + it);
     }
 
   options_list.symbol_list_options[move(name_option)] = symbol_list;
@@ -1489,17 +1482,17 @@ ParsingDriver::stoch_simul()
 void
 ParsingDriver::trend_component_model()
 {
-  const auto its = options_list.string_options.find("trend_component.name");
+  auto its = options_list.string_options.find("trend_component.name");
   if (its == options_list.string_options.end())
     error("You must pass the model_name option to the trend_component_model statement.");
   auto name = its->second;
 
-  const auto itvs = options_list.vector_str_options.find("trend_component.eqtags");
+  auto itvs = options_list.vector_str_options.find("trend_component.eqtags");
   if (itvs == options_list.vector_str_options.end())
     error("You must pass the eqtags option to the trend_component_model statement.");
   auto eqtags = itvs->second;
 
-  const auto itvs1 = options_list.vector_str_options.find("trend_component.targets");
+  auto itvs1 = options_list.vector_str_options.find("trend_component.targets");
   if (itvs1 == options_list.vector_str_options.end())
     error("You must pass the targets option to the trend_component_model statement.");
   auto targets = itvs1->second;
@@ -1511,13 +1504,13 @@ ParsingDriver::trend_component_model()
 void
 ParsingDriver::var_model()
 {
-  const auto its = options_list.string_options.find("var.model_name");
+  auto its = options_list.string_options.find("var.model_name");
   if (its == options_list.string_options.end())
     error("You must pass the model_name option to the var_model statement.");
   auto name = its->second;
 
   int order = 0;
-  const auto itn = options_list.num_options.find("var.order");
+  auto itn = options_list.num_options.find("var.order");
   if (itn != options_list.num_options.end())
     order = stoi(itn->second);
   else
@@ -1525,7 +1518,7 @@ ParsingDriver::var_model()
     error("You must pass the order option when passing a symbol list to the var_model statement");
 
   vector<string> eqtags;
-  const auto itvs = options_list.vector_str_options.find("var.eqtags");
+  auto itvs = options_list.vector_str_options.find("var.eqtags");
   if (itvs != options_list.vector_str_options.end())
     {
       eqtags = itvs->second;
@@ -1809,7 +1802,6 @@ ParsingDriver::copy_prior(const string &to_declaration_type, const string &to_na
                                                           from_declaration_type, from_name1,
                                                           from_name2, from_subsample_name,
                                                           mod_file->symbol_table));
-
 }
 
 void
@@ -2317,13 +2309,9 @@ ParsingDriver::ms_variance_decomposition()
 void
 ParsingDriver::svar()
 {
-  OptionsList::string_options_t::const_iterator it0, it1, it2;
-  OptionsList::num_options_t::const_iterator itn;
-  OptionsList::vec_int_options_t::const_iterator itv;
-
-  it0 = options_list.string_options.find("ms.coefficients");
-  it1 = options_list.string_options.find("ms.variances");
-  it2 = options_list.string_options.find("ms.constants");
+  auto it0 = options_list.string_options.find("ms.coefficients"),
+    it1 = options_list.string_options.find("ms.variances"),
+    it2 = options_list.string_options.find("ms.constants");
   if (it0 == options_list.string_options.end()
       && it1 == options_list.string_options.end()
       && it2 == options_list.string_options.end())
@@ -2337,14 +2325,14 @@ ParsingDriver::svar()
           && it2 != options_list.string_options.end()))
     error("You may only pass one of 'coefficients', 'variances', or 'constants'.");
 
-  itn = options_list.num_options.find("ms.chain");
-  if (itn == options_list.num_options.end())
+  if (auto itn = options_list.num_options.find("ms.chain");
+      itn == options_list.num_options.end())
     error("A chain option must be passed to the svar statement.");
   else if (stoi(itn->second) <= 0)
     error("The value passed to the chain option must be greater than zero.");
 
-  itv = options_list.vector_int_options.find("ms.equations");
-  if (itv != options_list.vector_int_options.end())
+  if (auto itv = options_list.vector_int_options.find("ms.equations");
+      itv != options_list.vector_int_options.end())
     for (int viit : itv->second)
       if (viit <= 0)
         error("The value(s) passed to the equation option must be greater than zero.");
@@ -2356,9 +2344,7 @@ ParsingDriver::svar()
 void
 ParsingDriver::markov_switching()
 {
-  OptionsList::num_options_t::const_iterator it0;
-
-  it0 = options_list.num_options.find("ms.chain");
+  auto it0 = options_list.num_options.find("ms.chain");
   if (it0 == options_list.num_options.end())
     error("A chain option must be passed to the markov_switching statement.");
   else if (stoi(it0->second) <= 0)
@@ -2420,12 +2406,7 @@ ParsingDriver::conditional_forecast()
 void
 ParsingDriver::plot_conditional_forecast(const string &periods)
 {
-  int nperiods;
-  if (periods.empty())
-    nperiods = -1;
-  else
-    nperiods = stoi(periods);
-
+  int nperiods = periods.empty() ? -1 : stoi(periods);
   mod_file->addStatement(make_unique<PlotConditionalForecastStatement>(nperiods, symbol_list));
   symbol_list.clear();
 }
@@ -2476,9 +2457,8 @@ ParsingDriver::add_model_equal(expr_t arg1, expr_t arg2)
 
   // Detect if the equation is tagged [static]
   bool is_static_only = false;
-  for (vector<pair<string, string>>::const_iterator it = eq_tags.begin();
-       it != eq_tags.end(); ++it)
-    if (it->first == "static")
+  for (auto & eq_tag : eq_tags)
+    if (eq_tag.first == "static")
       {
         is_static_only = true;
         break;
@@ -2676,13 +2656,13 @@ ParsingDriver::begin_pac_model()
 void
 ParsingDriver::pac_model()
 {
-  OptionsList::string_options_t::const_iterator it = options_list.string_options.find("pac.model_name");
+  auto it = options_list.string_options.find("pac.model_name");
   if (it == options_list.string_options.end())
     error("You must pass the model_name option to the pac_model statement.");
   auto name = it->second;
 
   bool pac_growth_is_param = false;
-  if (pac_growth != nullptr && dynamic_cast<VariableNode *>(pac_growth) != nullptr)
+  if (pac_growth && dynamic_cast<VariableNode *>(pac_growth))
     {
       set<int> params;
       pac_growth->collectVariables(SymbolType::parameter, params);
@@ -2694,7 +2674,7 @@ ParsingDriver::pac_model()
         pac_growth_is_param = false;
     }
 
-  string aux_model_name = "";
+  string aux_model_name;
   it = options_list.string_options.find("pac.aux_model_name");
   if (it != options_list.string_options.end())
     {
@@ -2710,7 +2690,7 @@ ParsingDriver::pac_model()
     if (pac_growth_is_param
         && (pac_steady_state_growth_rate_number >= 0 || pac_steady_state_growth_rate_symb_id >=0))
       warning("If growth option is constant, steady_state_growth is ignored");
-    else if (pac_growth != nullptr && !pac_growth_is_param
+    else if (pac_growth && !pac_growth_is_param
              && (pac_steady_state_growth_rate_number < 0 || pac_steady_state_growth_rate_symb_id < 0))
       error("The steady state growth rate of the target must be provided (steady_state_growth option) if option growth is not constant");
 
@@ -3025,15 +3005,15 @@ ParsingDriver::is_there_one_integer_argument() const
   if (stack_external_function_args.top().size() != 1)
     return { false, 0 };
 
-  auto *numNode = dynamic_cast<NumConstNode *>(stack_external_function_args.top().front());
-  auto *unaryNode = dynamic_cast<UnaryOpNode *>(stack_external_function_args.top().front());
+  auto numNode = dynamic_cast<NumConstNode *>(stack_external_function_args.top().front());
+  auto unaryNode = dynamic_cast<UnaryOpNode *>(stack_external_function_args.top().front());
 
-  if (numNode == nullptr && unaryNode == nullptr)
+  if (!numNode && !unaryNode)
     return { false, 0 };
 
   eval_context_t ectmp;
   double model_var_arg;
-  if (unaryNode == nullptr)
+  if (!unaryNode)
     {
       try
         {
@@ -3090,7 +3070,7 @@ ParsingDriver::add_model_var_or_external_function(const string &function_name, b
           nid = add_model_variable(mod_file->symbol_table.getID(function_name), static_cast<int>(rv.second));
           stack_external_function_args.pop();
           return nid;
-      }
+        }
     else
       { // e.g. this function has already been referenced (either ad hoc or through the external_function() statement
         // => check that the information matches previously declared info
@@ -3465,7 +3445,7 @@ ParsingDriver::add_init2shocks(const string &endo_name, const string &exo_name)
   if (mod_file->symbol_table.getType(symb_id_exo) != SymbolType::exogenous)
     error("init2shocks: " + exo_name + " should be an exogenous variable");
 
-  init2shocks.push_back(make_pair(symb_id_endo, symb_id_exo));
+  init2shocks.emplace_back(symb_id_endo, symb_id_exo);
 }
 
 void
diff --git a/src/Shocks.cc b/src/Shocks.cc
index 33e227814587ebcb0bbc00909e1c8df9391d34c9..230fd2788cfdac6eb566bf4921d04c187f184ea1 100644
--- a/src/Shocks.cc
+++ b/src/Shocks.cc
@@ -40,27 +40,26 @@ AbstractShocksStatement::writeDetShocks(ostream &output) const
 {
   int exo_det_length = 0;
 
-  for (const auto & det_shock : det_shocks)
+  for (const auto & [id, shock_vec] : det_shocks)
     {
-      int id = symbol_table.getTypeSpecificID(det_shock.first) + 1;
-      bool exo_det = (symbol_table.getType(det_shock.first) == SymbolType::exogenousDet);
+      bool exo_det = (symbol_table.getType(id) == SymbolType::exogenousDet);
 
-      for (const auto &it : det_shock.second)
+      for (const auto &it : shock_vec)
         {
-          const int &period1 = it.period1;
-          const int &period2 = it.period2;
-          const expr_t value = it.value;
+          int period1 = it.period1;
+          int period2 = it.period2;
+          expr_t value = it.value;
 
           output << "M_.det_shocks = [ M_.det_shocks;" << endl
                  << "struct('exo_det'," << static_cast<int>(exo_det)
-                 << ",'exo_id'," << id
+                 << ",'exo_id'," << symbol_table.getTypeSpecificID(id)+1
                  << ",'multiplicative'," << static_cast<int>(mshocks)
                  << ",'periods'," << period1 << ":" << period2
                  << ",'value',";
           value->writeOutput(output);
           output << ") ];" << endl;
 
-          if (exo_det && (period2 > exo_det_length))
+          if (exo_det && period2 > exo_det_length)
             exo_det_length = period2;
         }
     }
@@ -71,15 +70,13 @@ void
 AbstractShocksStatement::writeJsonDetShocks(ostream &output) const
 {
   output << R"("deterministic_shocks": [)";
-  for (auto it = det_shocks.begin();
-       it != det_shocks.end(); it++)
+  for (auto it = det_shocks.begin(); it != det_shocks.end(); ++it)
     {
       if (it != det_shocks.begin())
         output << ", ";
       output << R"({"var": ")" << symbol_table.getName(it->first) << R"(", )"
              << R"("values": [)";
-      for (auto it1 = it->second.begin();
-           it1 != it->second.end(); it1++)
+      for (auto it1 = it->second.begin(); it1 != it->second.end(); ++it1)
         {
           if (it1 != it->second.begin())
             output << ", ";
@@ -165,7 +162,7 @@ ShocksStatement::writeJsonOutput(ostream &output) const
       writeJsonDetShocks(output);
     }
   output<< R"(, "variance": [)";
-  for (auto it = var_shocks.begin(); it != var_shocks.end(); it++)
+  for (auto it = var_shocks.begin(); it != var_shocks.end(); ++it)
     {
       if (it != var_shocks.begin())
         output << ", ";
@@ -187,7 +184,7 @@ ShocksStatement::writeJsonOutput(ostream &output) const
     }
   output << "]"
          << R"(, "covariance": [)";
-  for (auto it = covar_shocks.begin(); it != covar_shocks.end(); it++)
+  for (auto it = covar_shocks.begin(); it != covar_shocks.end(); ++it)
     {
       if (it != covar_shocks.begin())
         output << ", ";
@@ -200,7 +197,7 @@ ShocksStatement::writeJsonOutput(ostream &output) const
     }
   output << "]"
          << R"(, "correlation": [)";
-  for (auto it = corr_shocks.begin(); it != corr_shocks.end(); it++)
+  for (auto it = corr_shocks.begin(); it != corr_shocks.end(); ++it)
     {
       if (it != corr_shocks.begin())
         output << ", ";
@@ -246,12 +243,10 @@ ShocksStatement::writeVarOrStdShock(ostream &output, var_and_std_shocks_t::const
 void
 ShocksStatement::writeVarAndStdShocks(ostream &output) const
 {
-  var_and_std_shocks_t::const_iterator it;
-
-  for (it = var_shocks.begin(); it != var_shocks.end(); it++)
+  for (auto it = var_shocks.begin(); it != var_shocks.end(); ++it)
     writeVarOrStdShock(output, it, false);
 
-  for (it = std_shocks.begin(); it != std_shocks.end(); it++)
+  for (auto it = std_shocks.begin(); it != std_shocks.end(); ++it)
     writeVarOrStdShock(output, it, true);
 }
 
@@ -302,12 +297,10 @@ ShocksStatement::writeCovarOrCorrShock(ostream &output, covar_and_corr_shocks_t:
 void
 ShocksStatement::writeCovarAndCorrShocks(ostream &output) const
 {
-  covar_and_corr_shocks_t::const_iterator it;
-
-  for (it = covar_shocks.begin(); it != covar_shocks.end(); it++)
+  for (auto it = covar_shocks.begin(); it != covar_shocks.end(); ++it)
     writeCovarOrCorrShock(output, it, false);
 
-  for (it = corr_shocks.begin(); it != corr_shocks.end(); it++)
+  for (auto it = corr_shocks.begin(); it != corr_shocks.end(); ++it)
     writeCovarOrCorrShock(output, it, true);
 }
 
@@ -317,32 +310,31 @@ ShocksStatement::checkPass(ModFileStructure &mod_file_struct, WarningConsolidati
   /* Error out if variables are not of the right type. This must be done here
      and not at parsing time (see #448).
      Also Determine if there is a calibrated measurement error */
-  for (auto var_shock : var_shocks)
+  for (auto [id, val] : var_shocks)
     {
-      if (symbol_table.getType(var_shock.first) != SymbolType::exogenous
-          && !symbol_table.isObservedVariable(var_shock.first))
+      if (symbol_table.getType(id) != SymbolType::exogenous
+          && !symbol_table.isObservedVariable(id))
         {
           cerr << "shocks: setting a variance on '"
-               << symbol_table.getName(var_shock.first) << "' is not allowed, because it is neither an exogenous variable nor an observed endogenous variable" << endl;
+               << symbol_table.getName(id) << "' is not allowed, because it is neither an exogenous variable nor an observed endogenous variable" << endl;
           exit(EXIT_FAILURE);
         }
     }
 
-  for (auto std_shock : std_shocks)
+  for (auto [id, val] : std_shocks)
     {
-      if (symbol_table.getType(std_shock.first) != SymbolType::exogenous
-          && !symbol_table.isObservedVariable(std_shock.first))
+      if (symbol_table.getType(id) != SymbolType::exogenous
+          && !symbol_table.isObservedVariable(id))
         {
           cerr << "shocks: setting a standard error on '"
-               << symbol_table.getName(std_shock.first) << "' is not allowed, because it is neither an exogenous variable nor an observed endogenous variable" << endl;
+               << symbol_table.getName(id) << "' is not allowed, because it is neither an exogenous variable nor an observed endogenous variable" << endl;
           exit(EXIT_FAILURE);
         }
     }
 
-  for (const auto & covar_shock : covar_shocks)
+  for (const auto & [ids, val] : covar_shocks)
     {
-      int symb_id1 = covar_shock.first.first;
-      int symb_id2 = covar_shock.first.second;
+      int symb_id1 = ids.first, symb_id2 = ids.second;
 
       if (!((symbol_table.getType(symb_id1) == SymbolType::exogenous
              && symbol_table.getType(symb_id2) == SymbolType::exogenous)
@@ -356,10 +348,9 @@ ShocksStatement::checkPass(ModFileStructure &mod_file_struct, WarningConsolidati
         }
     }
 
-  for (const auto & corr_shock : corr_shocks)
+  for (const auto & [ids, val] : corr_shocks)
     {
-      int symb_id1 = corr_shock.first.first;
-      int symb_id2 = corr_shock.first.second;
+      int symb_id1 = ids.first, symb_id2 = ids.second;
 
       if (!((symbol_table.getType(symb_id1) == SymbolType::exogenous
              && symbol_table.getType(symb_id2) == SymbolType::exogenous)
@@ -377,36 +368,35 @@ ShocksStatement::checkPass(ModFileStructure &mod_file_struct, WarningConsolidati
   mod_file_struct.calibrated_measurement_errors |= has_calibrated_measurement_errors();
 
   // Fill in mod_file_struct.parameters_with_shocks_values (related to #469)
-  for (auto var_shock : var_shocks)
-    var_shock.second->collectVariables(SymbolType::parameter, mod_file_struct.parameters_within_shocks_values);
-  for (auto std_shock : std_shocks)
-    std_shock.second->collectVariables(SymbolType::parameter, mod_file_struct.parameters_within_shocks_values);
-  for (const auto & covar_shock : covar_shocks)
-    covar_shock.second->collectVariables(SymbolType::parameter, mod_file_struct.parameters_within_shocks_values);
-  for (const auto & corr_shock : corr_shocks)
-    corr_shock.second->collectVariables(SymbolType::parameter, mod_file_struct.parameters_within_shocks_values);
-
+  for (auto [id, val] : var_shocks)
+    val->collectVariables(SymbolType::parameter, mod_file_struct.parameters_within_shocks_values);
+  for (auto [id, val] : std_shocks)
+    val->collectVariables(SymbolType::parameter, mod_file_struct.parameters_within_shocks_values);
+  for (const auto &[ids, val] : covar_shocks)
+    val->collectVariables(SymbolType::parameter, mod_file_struct.parameters_within_shocks_values);
+  for (const auto &[ids, val] : corr_shocks)
+    val->collectVariables(SymbolType::parameter, mod_file_struct.parameters_within_shocks_values);
 }
 
 bool
 ShocksStatement::has_calibrated_measurement_errors() const
 {
-  for (auto var_shock : var_shocks)
-    if (symbol_table.isObservedVariable(var_shock.first))
+  for (auto [id, val] : var_shocks)
+    if (symbol_table.isObservedVariable(id))
       return true;
 
-  for (auto std_shock : std_shocks)
-    if (symbol_table.isObservedVariable(std_shock.first))
+  for (auto [id, val] : std_shocks)
+    if (symbol_table.isObservedVariable(id))
       return true;
 
-  for (const auto & covar_shock : covar_shocks)
-    if (symbol_table.isObservedVariable(covar_shock.first.first)
-        || symbol_table.isObservedVariable(covar_shock.first.second))
+  for (const auto & [ids, val] : covar_shocks)
+    if (symbol_table.isObservedVariable(ids.first)
+        || symbol_table.isObservedVariable(ids.second))
       return true;
 
-  for (const auto & corr_shock : corr_shocks)
-    if (symbol_table.isObservedVariable(corr_shock.first.first)
-        || symbol_table.isObservedVariable(corr_shock.first.second))
+  for (const auto & [ids, val] : corr_shocks)
+    if (symbol_table.isObservedVariable(ids.first)
+        || symbol_table.isObservedVariable(ids.second))
       return true;
 
   return false;
@@ -450,11 +440,6 @@ ConditionalForecastPathsStatement::checkPass(ModFileStructure &mod_file_struct,
         // Period1 < Period2, as enforced in ParsingDriver::add_period()
         this_path_length = max(this_path_length, elem.period2);
       path_length = max(this_path_length, path_length);
-      //      else if (path_length != this_path_length)
-      //        {
-      //          cerr << "conditional_forecast_paths: all constrained paths must have the same length!" << endl;
-      //          exit(EXIT_FAILURE);
-      //        }
     }
 }
 
@@ -466,15 +451,13 @@ ConditionalForecastPathsStatement::writeOutput(ostream &output, const string &ba
          << "constrained_paths_ = NaN(" << paths.size() << ", " << path_length << ");" << endl;
 
   int k = 1;
-  for (auto it = paths.begin();
-       it != paths.end(); it++, k++)
+  for (auto it = paths.begin(); it != paths.end(); ++it, k++)
     {
       if (it == paths.begin())
         output << "constrained_vars_ = " << symbol_table.getTypeSpecificID(it->first) + 1 << ";" << endl;
       else
         output << "constrained_vars_ = [constrained_vars_; " << symbol_table.getTypeSpecificID(it->first) + 1 << "];" << endl;
-      const vector<AbstractShocksStatement::DetShockElement> &elems = it->second;
-      for (auto elem : elems)
+      for (const auto &elem : it->second)
         for (int j = elem.period1; j <= elem.period2; j++)
           {
             output << "constrained_paths_(" << k << "," << j << ")=";
@@ -489,13 +472,13 @@ ConditionalForecastPathsStatement::writeJsonOutput(ostream &output) const
 {
   output << R"({"statementName": "conditional_forecast_paths")"
          << R"(, "paths": [)";
-  for (auto it = paths.begin(); it != paths.end(); it++)
+  for (auto it = paths.begin(); it != paths.end(); ++it)
     {
       if (it != paths.begin())
         output << ", ";
       output << R"({"var": ")" << symbol_table.getName(it->first) << R"(", )"
              << R"("values": [)";
-      for (auto it1 = it->second.begin(); it1 != it->second.end(); it1++)
+      for (auto it1 = it->second.begin(); it1 != it->second.end(); ++it1)
         {
           if (it1 != it->second.begin())
             output << ", ";
@@ -540,7 +523,7 @@ MomentCalibration::writeJsonOutput(ostream &output) const
 {
   output << R"({"statementName": "moment_calibration")"
          << R"(, "moment_calibration_criteria": [)";
-  for (auto it = constraints.begin(); it != constraints.end(); it++)
+  for (auto it = constraints.begin(); it != constraints.end(); ++it)
     {
       if (it != constraints.begin())
         output << ", ";
@@ -598,7 +581,7 @@ IrfCalibration::writeJsonOutput(ostream &output) const
     }
 
   output << R"(, "irf_restrictions": [)";
-  for (auto it = constraints.begin(); it != constraints.end(); it++)
+  for (auto it = constraints.begin(); it != constraints.end(); ++it)
     {
       if (it != constraints.begin())
         output << ", ";
@@ -627,9 +610,9 @@ ShockGroupsStatement::writeOutput(ostream &output, const string &basename, bool
 {
   int i = 1;
   bool unique_label = true;
-  for (auto it = shock_groups.begin(); it != shock_groups.end(); it++, unique_label = true)
+  for (auto it = shock_groups.begin(); it != shock_groups.end(); ++it, unique_label = true)
     {
-      for (auto it1 = it+1; it1 != shock_groups.end(); it1++)
+      for (auto it1 = it+1; it1 != shock_groups.end(); ++it1)
         if (it->name == it1->name)
           {
             unique_label = false;
@@ -658,9 +641,9 @@ ShockGroupsStatement::writeJsonOutput(ostream &output) const
   output << R"({"statementName": "shock_groups", "name": ")" << name << R"(", "groups": [)";
   bool unique_label = true;
   bool printed_group = false;
-  for (auto it = shock_groups.begin(); it != shock_groups.end(); it++, unique_label = true)
+  for (auto it = shock_groups.begin(); it != shock_groups.end(); ++it, unique_label = true)
     {
-      for (auto it1 = it+1; it1 != shock_groups.end(); it1++)
+      for (auto it1 = it+1; it1 != shock_groups.end(); ++it1)
         if (it->name == it1->name)
           {
             unique_label = false;
@@ -675,7 +658,7 @@ ShockGroupsStatement::writeJsonOutput(ostream &output) const
             printed_group = true;
           output << R"({"group_name": ")" << it->name << R"(",)"
                  << R"("shocks": [)";
-          for (auto it1 = it->list.begin(); it1 != it->list.end(); it1++)
+          for (auto it1 = it->list.begin(); it1 != it->list.end(); ++it1)
             {
               if (it1 != it->list.begin())
                 output << ", ";
diff --git a/src/SigmaeInitialization.cc b/src/SigmaeInitialization.cc
index da2e26da1f340ecb2e0f560c53131d24d4622f21..9fbcf3cc1846c33034ae17c7a9c56ead737b9db3 100644
--- a/src/SigmaeInitialization.cc
+++ b/src/SigmaeInitialization.cc
@@ -1,5 +1,5 @@
 /*
- * Copyright © 2003-2015 Dynare Team
+ * Copyright © 2003-2019 Dynare Team
  *
  * This file is part of Dynare.
  *
@@ -52,8 +52,7 @@ SigmaeStatement::determineMatrixForm(const matrix_t &matrix) noexcept(false)
   // Checking if matrix is triangular (upper or lower):
   // each row has one element more or less than the previous one
   // and first or last one has one element.
-  matrix_t::const_iterator ir;
-  for (ir = matrix.begin(), ir++; ir != matrix.end(); ir++, nbe += inc)
+  for (auto ir = ++matrix.begin(); ir != matrix.end(); ++ir, nbe += inc)
     if (ir->size() != nbe)
       throw MatrixFormException();
 
@@ -63,13 +62,12 @@ SigmaeStatement::determineMatrixForm(const matrix_t &matrix) noexcept(false)
 void
 SigmaeStatement::writeOutput(ostream &output, const string &basename, bool minimal_workspace) const
 {
-  size_t ic, ic1, ir, ir1;
-
   output << "M_.Sigma_e = [..." << endl;
-  for (ir = 0; ir < matrix.size(); ir++)
+  for (size_t ir = 0; ir < matrix.size(); ir++)
     {
-      for (ic = 0; ic < matrix.size(); ic++)
+      for (size_t ic = 0; ic < matrix.size(); ic++)
         {
+          size_t ic1, ir1;
           if (ic >= ir && matrix_form == MatrixForm::upper)
             {
               ic1 = ic-ir;
diff --git a/src/Statement.cc b/src/Statement.cc
index fd5ac82ce029d1744ea3cb66e1d344299711dd6b..850bde2b5ee1ff228ef29e84068a88b719ae5962 100644
--- a/src/Statement.cc
+++ b/src/Statement.cc
@@ -92,48 +92,48 @@ VerbatimStatement::writeJsonOutput(ostream &output) const
 void
 OptionsList::writeOutput(ostream &output) const
 {
-  for (const auto & num_option : num_options)
-    output << "options_." << num_option.first << " = " << num_option.second << ";" << endl;
+  for (const auto & [name, val] : num_options)
+    output << "options_." << name << " = " << val << ";" << endl;
 
-  for (const auto & paired_num_option : paired_num_options)
-    output << "options_." << paired_num_option.first << " = [" << paired_num_option.second.first << "; "
-           << paired_num_option.second.second << "];" << endl;
+  for (const auto & [name, vals] : paired_num_options)
+    output << "options_." << name << " = [" << vals.first << "; "
+           << vals.second << "];" << endl;
 
-  for (const auto & string_option : string_options)
-    output << "options_." << string_option.first << " = '" << string_option.second << "';" << endl;
+  for (const auto & [name, val] : string_options)
+    output << "options_." << name << " = '" << val << "';" << endl;
 
-  for (const auto & date_option : date_options)
-    output << "options_." << date_option.first << " = " << date_option.second << ";" << endl;
+  for (const auto & [name, val] : date_options)
+    output << "options_." << name << " = " << val << ";" << endl;
 
-  for (const auto & symbol_list_option : symbol_list_options)
-    symbol_list_option.second.writeOutput("options_." + symbol_list_option.first, output);
+  for (const auto & [name, list] : symbol_list_options)
+    list.writeOutput("options_." + name, output);
 
-  for (const auto & vector_int_option : vector_int_options)
+  for (const auto & [name, vals] : vector_int_options)
     {
-      output << "options_." << vector_int_option.first << " = ";
-      if (vector_int_option.second.size() > 1)
+      output << "options_." << name << " = ";
+      if (vals.size() > 1)
         {
           output << "[";
-          for (int viit : vector_int_option.second)
+          for (int viit : vals)
             output << viit << ";";
           output << "];" << endl;
         }
       else
-        output << vector_int_option.second.front() << ";" << endl;
+        output << vals.front() << ";" << endl;
     }
 
-  for (const auto & vector_str_option : vector_str_options)
+  for (const auto & [name, vals] : vector_str_options)
     {
-      output << "options_." << vector_str_option.first << " = ";
-      if (vector_str_option.second.size() > 1)
+      output << "options_." << name << " = ";
+      if (vals.size() > 1)
         {
           output << "{";
-          for (const auto & viit : vector_str_option.second)
+          for (const auto & viit : vals)
             output << "'" << viit << "';";
           output << "};" << endl;
         }
       else
-        output << vector_str_option.second.front() << ";" << endl;
+        output << vals.front() << ";" << endl;
     }
 }
 
@@ -141,8 +141,8 @@ void
 OptionsList::writeOutput(ostream &output, const string &option_group) const
 {
   // Initialize option_group as an empty struct iff the field does not exist!
-  size_t idx = option_group.find_last_of(".");
-  if (idx != string::npos)
+  if (size_t idx = option_group.find_last_of(".");
+      idx != string::npos)
     {
       output << "if ~isfield(" << option_group.substr(0, idx) << ",'" << option_group.substr(idx+1) << "')" << endl;
       output << "    " << option_group << " = struct();" << endl;
@@ -151,48 +151,48 @@ OptionsList::writeOutput(ostream &output, const string &option_group) const
   else
     output << option_group << " = struct();" << endl;
 
-  for (const auto & num_option : num_options)
-    output << option_group << "." << num_option.first << " = " << num_option.second << ";" << endl;
+  for (const auto & [name, val] : num_options)
+    output << option_group << "." << name << " = " << val << ";" << endl;
 
-  for (const auto & paired_num_option : paired_num_options)
-    output << option_group << "." << paired_num_option.first << " = [" << paired_num_option.second.first << "; "
-           << paired_num_option.second.second << "];" << endl;
+  for (const auto & [name, vals] : paired_num_options)
+    output << option_group << "." << name << " = [" << vals.first << "; "
+           << vals.second << "];" << endl;
 
-  for (const auto & string_option : string_options)
-    output << option_group << "." << string_option.first << " = '" << string_option.second << "';" << endl;
+  for (const auto & [name, val] : string_options)
+    output << option_group << "." << name << " = '" << val << "';" << endl;
 
-  for (const auto & date_option : date_options)
-    output << option_group << "." << date_option.first << " = " << date_option.second << ";" << endl;
+  for (const auto & [name, val] : date_options)
+    output << option_group << "." << name << " = " << val << ";" << endl;
 
-  for (const auto & symbol_list_option : symbol_list_options)
-    symbol_list_option.second.writeOutput(option_group + "." + symbol_list_option.first, output);
+  for (const auto & [name, list] : symbol_list_options)
+    list.writeOutput(option_group + "." + name, output);
 
-  for (const auto & vector_int_option : vector_int_options)
+  for (const auto & [name, vals] : vector_int_options)
     {
-      output << option_group << "." << vector_int_option.first << " = ";
-      if (vector_int_option.second.size() > 1)
+      output << option_group << "." << name << " = ";
+      if (vals.size() > 1)
         {
           output << "[";
-          for (int viit : vector_int_option.second)
+          for (int viit : vals)
             output << viit << ";";
           output << "];" << endl;
         }
       else
-        output <<  vector_int_option.second.front() << ";" << endl;
+        output << vals.front() << ";" << endl;
     }
 
-  for (const auto & vector_str_option : vector_str_options)
+  for (const auto & [name, vals] : vector_str_options)
     {
-      output << option_group << "." << vector_str_option.first << " = ";
-      if (vector_str_option.second.size() > 1)
+      output << option_group << "." << name << " = ";
+      if (vals.size() > 1)
         {
           output << "{";
-          for (const auto & viit : vector_str_option.second)
+          for (const auto & viit : vals)
             output << "'" << viit << "';";
           output << "};" << endl;
         }
       else
-        output <<  vector_str_option.second.front() << ";" << endl;
+        output << vals.front() << ";" << endl;
     }
 }
 
@@ -207,7 +207,7 @@ OptionsList::writeJsonOutput(ostream &output) const
        it != num_options.end();)
     {
       output << R"(")"<< it->first << R"(": )" << it->second;
-      it++;
+      ++it;
       if (it != num_options.end()
           || !(paired_num_options.empty()
                && string_options.empty()
@@ -221,7 +221,7 @@ OptionsList::writeJsonOutput(ostream &output) const
        it != paired_num_options.end();)
     {
       output << R"(")"<< it->first << R"(": [)" << it->second.first << " " << it->second.second << "]";
-      it++;
+      ++it;
       if (it != paired_num_options.end()
           || !(string_options.empty()
                && date_options.empty()
@@ -234,7 +234,7 @@ OptionsList::writeJsonOutput(ostream &output) const
        it != string_options.end();)
     {
       output << R"(")"<< it->first << R"(": ")" << it->second << R"(")";
-      it++;
+      ++it;
       if (it != string_options.end()
           || !(date_options.empty()
                && symbol_list_options.empty()
@@ -246,7 +246,7 @@ OptionsList::writeJsonOutput(ostream &output) const
        it != date_options.end();)
     {
       output << R"(")"<< it->first << R"(": ")" << it->second << R"(")";
-      it++;
+      ++it;
       if (it != date_options.end()
           || !(symbol_list_options.empty()
                && vector_int_options.empty()))
@@ -259,7 +259,7 @@ OptionsList::writeJsonOutput(ostream &output) const
       output << R"(")"<< it->first << R"(": {)";
       it->second.writeJsonOutput(output);
       output << "}";
-      it++;
+      ++it;
       if (it != symbol_list_options.end()
           || !vector_int_options.empty())
         output << ", ";
@@ -275,7 +275,7 @@ OptionsList::writeJsonOutput(ostream &output) const
                viit != it->second.end();)
             {
               output << *viit;
-              viit++;
+              ++viit;
               if (viit != it->second.end())
                 output << ", ";
             }
@@ -283,7 +283,7 @@ OptionsList::writeJsonOutput(ostream &output) const
       else
         output << it->second.front() << endl;
       output << "]";
-      it++;
+      ++it;
       if (it != vector_int_options.end())
         output << ", ";
     }
@@ -298,7 +298,7 @@ OptionsList::writeJsonOutput(ostream &output) const
                viit != it->second.end();)
             {
               output << R"(")" << *viit << R"(")";
-              viit++;
+              ++viit;
               if (viit != it->second.end())
                 output << ", ";
             }
@@ -306,7 +306,7 @@ OptionsList::writeJsonOutput(ostream &output) const
       else
         output << it->second.front() << endl;
       output << "]";
-      it++;
+      ++it;
       if (it != vector_str_options.end())
         output << ", ";
     }
diff --git a/src/StaticModel.cc b/src/StaticModel.cc
index 9b7a0263bb3496dd197c5288369829d27ef9b071..2ae368c9d3dae8c8ebe60527c053cce2e7cdc5ae 100644
--- a/src/StaticModel.cc
+++ b/src/StaticModel.cc
@@ -164,11 +164,11 @@ StaticModel::StaticModel(const DynamicModel &m) :
       // Detect if equation is marked [dynamic]
       bool is_dynamic_only = false;
       vector<pair<string, string>> eq_tags;
-      for (const auto & equation_tag : equation_tags)
-        if (equation_tag.first == i)
+      for (const auto & [tagged_eq, tag_pair] : equation_tags)
+        if (tagged_eq == i)
           {
-            eq_tags.push_back(equation_tag.second);
-            if (equation_tag.second.first == "dynamic")
+            eq_tags.push_back(tag_pair);
+            if (tag_pair.first == "dynamic")
               is_dynamic_only = true;
           }
 
@@ -206,9 +206,9 @@ StaticModel::StaticModel(const DynamicModel &m) :
 void
 StaticModel::compileDerivative(ofstream &code_file, unsigned int &instruction_number, int eq, int symb_id, map_idx_t &map_idx, temporary_terms_t temporary_terms) const
 {
-  auto it = derivatives[1].find({ eq, getDerivID(symbol_table.getID(SymbolType::endogenous, symb_id), 0) });
-  if (it != derivatives[1].end())
-    (it->second)->compile(code_file, instruction_number, false, temporary_terms, map_idx, false, false);
+  if (auto it = derivatives[1].find({ eq, getDerivID(symbol_table.getID(SymbolType::endogenous, symb_id), 0) });
+      it != derivatives[1].end())
+    it->second->compile(code_file, instruction_number, false, temporary_terms, map_idx, false, false);
   else
     {
       FLDZ_ fldz;
@@ -219,9 +219,9 @@ StaticModel::compileDerivative(ofstream &code_file, unsigned int &instruction_nu
 void
 StaticModel::compileChainRuleDerivative(ofstream &code_file, unsigned int &instruction_number, int eqr, int varr, int lag, map_idx_t &map_idx, temporary_terms_t temporary_terms) const
 {
-  auto it = first_chain_rule_derivatives.find({ eqr, varr, lag });
-  if (it != first_chain_rule_derivatives.end())
-    (it->second)->compile(code_file, instruction_number, false, temporary_terms, map_idx, false, false);
+  if (auto it = first_chain_rule_derivatives.find({ eqr, varr, lag });
+      it != first_chain_rule_derivatives.end())
+    it->second->compile(code_file, instruction_number, false, temporary_terms, map_idx, false, false);
   else
     {
       FLDZ_ fldz;
@@ -435,7 +435,7 @@ StaticModel::writeModelEquationsOrdered_M(const string &basename) const
               output << "  " << "% //Temporary variables" << endl;
               for (auto it : v_temporary_terms[block][i])
                 {
-                  if (dynamic_cast<AbstractExternalFunctionNode *>(it) != nullptr)
+                  if (dynamic_cast<AbstractExternalFunctionNode *>(it))
                     it->writeExternalFunctionOutput(output, local_output_type, tt2, {}, tef_terms);
 
                   output << "  " <<  sps;
@@ -585,8 +585,7 @@ StaticModel::writeModelEquationsCode(const string &basename, map_idx_t map_idx)
                            0,
                            0,
                            u_count_int,
-                           symbol_table.endo_nbr()
-                           );
+                           symbol_table.endo_nbr());
   fbeginblock.write(code_file, instruction_number);
 
   // Add a mapping form node ID to temporary terms order
@@ -608,13 +607,12 @@ StaticModel::writeModelEquationsCode(const string &basename, map_idx_t map_idx)
 
   vector<vector<pair<int, int>>> my_derivatives(symbol_table.endo_nbr());
   count_u = symbol_table.endo_nbr();
-  for (const auto & first_derivative : derivatives[1])
+  for (const auto & [indices, d1] : derivatives[1])
     {
-      int deriv_id = first_derivative.first[1];
+      int deriv_id = indices[1];
       if (getTypeByDerivID(deriv_id) == SymbolType::endogenous)
         {
-          expr_t d1 = first_derivative.second;
-          unsigned int eq = first_derivative.first[0];
+          unsigned int eq = indices[0];
           int symb = getSymbIDByDerivID(deriv_id);
           unsigned int var = symbol_table.getTypeSpecificID(symb);
           FNUMEXPR_ fnumexpr(FirstEndoDerivative, eq, var);
@@ -636,7 +634,7 @@ StaticModel::writeModelEquationsCode(const string &basename, map_idx_t map_idx)
       fldr.write(code_file, instruction_number);
       if (my_derivatives[i].size())
         {
-          for (auto it = my_derivatives[i].begin(); it != my_derivatives[i].end(); it++)
+          for (auto it = my_derivatives[i].begin(); it != my_derivatives[i].end(); ++it)
             {
               FLDSU_ fldsu(it->second);
               fldsu.write(code_file, instruction_number);
@@ -671,13 +669,12 @@ StaticModel::writeModelEquationsCode(const string &basename, map_idx_t map_idx)
   temporary_terms_t tt2, tt3;
 
   // The Jacobian if we have to solve the block determinsitic bloc
-  for (const auto & first_derivative : derivatives[1])
+  for (const auto & [indices, d1] : derivatives[1])
     {
-      int deriv_id = first_derivative.first[1];
+      int deriv_id = indices[1];
       if (getTypeByDerivID(deriv_id) == SymbolType::endogenous)
         {
-          expr_t d1 = first_derivative.second;
-          unsigned int eq = first_derivative.first[0];
+          unsigned int eq = indices[0];
           int symb = getSymbIDByDerivID(deriv_id);
           unsigned int var = symbol_table.getTypeSpecificID(symb);
           FNUMEXPR_ fnumexpr(FirstEndoDerivative, eq, var);
@@ -780,8 +777,7 @@ StaticModel::writeModelEquationsCode_Block(const string &basename, map_idx_t map
                                0,
                                0,
                                u_count_int,
-                               /*symbol_table.endo_nbr()*/ block_size
-                               );
+                               block_size);
 
       fbeginblock.write(code_file, instruction_number);
 
@@ -799,7 +795,7 @@ StaticModel::writeModelEquationsCode_Block(const string &basename, map_idx_t map
             {
               for (auto it : v_temporary_terms[block][i])
                 {
-                  if (dynamic_cast<AbstractExternalFunctionNode *>(it) != nullptr)
+                  if (dynamic_cast<AbstractExternalFunctionNode *>(it))
                     it->compileExternalFunctionOutput(code_file, instruction_number, false, tt2, map_idx, false, false, tef_terms);
 
                   FNUMEXPR_ fnumexpr(TemporaryTerm, static_cast<int>(map_idx.find(it->idx)->second));
@@ -872,8 +868,8 @@ StaticModel::writeModelEquationsCode_Block(const string &basename, map_idx_t map
       fendequ.write(code_file, instruction_number);
 
       // The Jacobian if we have to solve the block
-      if    (simulation_type != EVALUATE_BACKWARD
-             && simulation_type != EVALUATE_FORWARD)
+      if (simulation_type != EVALUATE_BACKWARD
+          && simulation_type != EVALUATE_FORWARD)
         {
           switch (simulation_type)
             {
@@ -988,7 +984,7 @@ StaticModel::writeModelEquationsCode_Block(const string &basename, map_idx_t map
             {
               for (const auto &it : v_temporary_terms_local[block][i])
                 {
-                  if (dynamic_cast<AbstractExternalFunctionNode *>(it) != nullptr)
+                  if (dynamic_cast<AbstractExternalFunctionNode *>(it))
                     it->compileExternalFunctionOutput(code_file, instruction_number, false, tt3, map_idx2[block], false, false, tef_terms2);
 
                   FNUMEXPR_ fnumexpr(TemporaryTerm, static_cast<int>(map_idx2[block].find(it->idx)->second));
@@ -1116,7 +1112,7 @@ StaticModel::writeModelEquationsCode_Block(const string &basename, map_idx_t map
 }
 
 void
-StaticModel::Write_Inf_To_Bin_File_Block(const string &basename, const int &num,
+StaticModel::Write_Inf_To_Bin_File_Block(const string &basename, int num,
                                          int &u_count_int, bool &file_open) const
 {
   int j;
@@ -1170,14 +1166,14 @@ map<tuple<int, int, int>, expr_t>
 StaticModel::collect_first_order_derivatives_endogenous()
 {
   map<tuple<int, int, int>, expr_t> endo_derivatives;
-  for (auto & first_derivative : derivatives[1])
+  for (auto & [indices, d1] : derivatives[1])
     {
-      if (getTypeByDerivID(first_derivative.first[1]) == SymbolType::endogenous)
+      if (getTypeByDerivID(indices[1]) == SymbolType::endogenous)
         {
-          int eq = first_derivative.first[0];
-          int var = symbol_table.getTypeSpecificID(getSymbIDByDerivID(first_derivative.first[1]));
+          int eq = indices[0];
+          int var = symbol_table.getTypeSpecificID(getSymbIDByDerivID(indices[1]));
           int lag = 0;
-          endo_derivatives[{ eq, var, lag }] = first_derivative.second;
+          endo_derivatives[{ eq, var, lag }] = d1;
         }
     }
   return endo_derivatives;
@@ -1490,10 +1486,9 @@ StaticModel::writeStaticModel(const string &basename,
                           temporary_terms_idxs,
                           tt_output[1], output_type, tef_terms);
 
-      for (const auto & first_derivative : derivatives[1])
+      for (const auto & [indices, d1] : derivatives[1])
         {
-          auto [eq, var] = vectorToTuple<2>(first_derivative.first);
-          expr_t d1 = first_derivative.second;
+          auto [eq, var] = vectorToTuple<2>(indices);
 
           jacobianHelper(d_output[1], eq, getJacobCol(var), output_type);
           d_output[1] << "=";
@@ -1520,10 +1515,8 @@ StaticModel::writeStaticModel(const string &basename,
         ostringstream col0_output, col1_output, col2_output;
 
         int k = 0; // Current line index in the 3-column matrix
-        for (const auto &dit : derivatives[i])
+        for (const auto &[vidx, d] : derivatives[i])
           {
-            const vector<int> &vidx = dit.first;
-            expr_t d = dit.second;
             int eq = vidx[0];
 
             int col_idx = 0;
@@ -2081,7 +2074,6 @@ StaticModel::writeStaticBlockMFSFile(const string &basename) const
 
   for (int b = 0; b < static_cast<int>(nb_blocks); b++)
     {
-
       set<int> local_var;
 
       output << "    case " << b+1 << endl;
@@ -2111,8 +2103,8 @@ void
 StaticModel::writeOutput(ostream &output, bool block) const
 {
   output << "M_.static_tmp_nbr = [";
-  for (size_t i = 0; i < temporary_terms_derivatives.size(); i++)
-    output << temporary_terms_derivatives[i].size() << "; ";
+  for (const auto & temporary_terms_derivative : temporary_terms_derivatives)
+    output << temporary_terms_derivative.size() << "; ";
   output << "];" << endl;
 
   if (!block)
@@ -2149,13 +2141,13 @@ StaticModel::writeOutput(ostream &output, bool block) const
     output << " " << equation_reordered[i]+1;
   output << "];" << endl;
 
-  map<pair<int, int>,  int>  row_incidence;
-  for (const auto & first_derivative : derivatives[1])
+  map<pair<int, int>, int> row_incidence;
+  for (const auto & [indices, d1] : derivatives[1])
     {
-      int deriv_id = first_derivative.first[1];
+      int deriv_id = indices[1];
       if (getTypeByDerivID(deriv_id) == SymbolType::endogenous)
         {
-          int eq = first_derivative.first[0];
+          int eq = indices[0];
           int symb = getSymbIDByDerivID(deriv_id);
           int var = symbol_table.getTypeSpecificID(symb);
           //int lag = getLagByDerivID(deriv_id);
@@ -2230,12 +2222,9 @@ StaticModel::get_Derivatives(int block)
           if (dynamic_jacobian.find({ lag, eqr, varr }) != dynamic_jacobian.end())
             {
               bool OK = true;
-              auto its = Derivatives.find({ lag, eq, var, eqr, varr });
-              if (its != Derivatives.end())
-                {
-                  if (its->second == 2)
-                    OK = false;
-                }
+              if (auto its = Derivatives.find({ lag, eq, var, eqr, varr });
+                  its != Derivatives.end() && its->second == 2)
+                OK = false;
 
               if (OK)
                 {
@@ -2392,7 +2381,7 @@ StaticModel::writeAuxVarInitval(ostream &output, ExprNodeOutputType output_type)
 }
 
 void
-StaticModel::writeSetAuxiliaryVariables(const string &basename, const bool julia) const
+StaticModel::writeSetAuxiliaryVariables(const string &basename, bool julia) const
 {
   ostringstream output_func_body;
   writeAuxVarRecursiveDefinitions(output_func_body, ExprNodeOutputType::matlabStaticModel);
@@ -2466,10 +2455,10 @@ StaticModel::writeJsonAuxVarRecursiveDefinitions(ostream &output) const
       {
         vector<string> efout;
         dynamic_cast<ExprNode *>(aux_equation)->writeJsonExternalFunctionOutput(efout,
-                                                                                    temporary_terms,
-                                                                                    tef_terms,
-                                                                                    false);
-        for (vector<string>::const_iterator it = efout.begin(); it != efout.end(); it++)
+                                                                                temporary_terms,
+                                                                                tef_terms,
+                                                                                false);
+        for (auto it = efout.begin(); it != efout.end(); ++it)
           {
             if (it != efout.begin())
               output << ", ";
@@ -2509,10 +2498,9 @@ StaticModel::writeParamsDerivativesFile(const string &basename, bool julia) cons
   for (const auto &it : params_derivs_temporary_terms)
     writeTemporaryTerms(it.second, temp_term_union, params_derivs_temporary_terms_idxs, tt_output, output_type, tef_terms);
 
-  for (const auto & residuals_params_derivative : params_derivatives.find({ 0, 1 })->second)
+  for (const auto & [indices, d1] : params_derivatives.find({ 0, 1 })->second)
     {
-      auto [eq, param] = vectorToTuple<2>(residuals_params_derivative.first);
-      expr_t d1 = residuals_params_derivative.second;
+      auto [eq, param] = vectorToTuple<2>(indices);
 
       int param_col = symbol_table.getTypeSpecificID(getSymbIDByDerivID(param)) + 1;
 
@@ -2523,10 +2511,9 @@ StaticModel::writeParamsDerivativesFile(const string &basename, bool julia) cons
       jacobian_output << ";" << endl;
     }
 
-  for (const auto & jacobian_params_derivative : params_derivatives.find({ 1, 1 })->second)
+  for (const auto & [indices, d2] : params_derivatives.find({ 1, 1 })->second)
     {
-      auto [eq, var, param] = vectorToTuple<3>(jacobian_params_derivative.first);
-      expr_t d2 = jacobian_params_derivative.second;
+      auto [eq, var, param] = vectorToTuple<3>(indices);
 
       int var_col = symbol_table.getTypeSpecificID(getSymbIDByDerivID(var)) + 1;
       int param_col = symbol_table.getTypeSpecificID(getSymbIDByDerivID(param)) + 1;
@@ -2539,10 +2526,9 @@ StaticModel::writeParamsDerivativesFile(const string &basename, bool julia) cons
     }
 
   int i = 1;
-  for (const auto &it : params_derivatives.find({ 0, 2 })->second)
+  for (const auto &[indices, d2] : params_derivatives.find({ 0, 2 })->second)
     {
-      auto [eq, param1, param2] = vectorToTuple<3>(it.first);
-      expr_t d2 = it.second;
+      auto [eq, param1, param2] = vectorToTuple<3>(indices);
 
       int param1_col = symbol_table.getTypeSpecificID(getSymbIDByDerivID(param1)) + 1;
       int param2_col = symbol_table.getTypeSpecificID(getSymbIDByDerivID(param2)) + 1;
@@ -2578,10 +2564,9 @@ StaticModel::writeParamsDerivativesFile(const string &basename, bool julia) cons
     }
 
   i = 1;
-  for (const auto &it : params_derivatives.find({ 1, 2 })->second)
+  for (const auto &[indices, d2] : params_derivatives.find({ 1, 2 })->second)
     {
-      auto [eq, var, param1, param2] = vectorToTuple<4>(it.first);
-      expr_t d2 = it.second;
+      auto [eq, var, param1, param2] = vectorToTuple<4>(indices);
 
       int var_col = symbol_table.getTypeSpecificID(getSymbIDByDerivID(var)) + 1;
       int param1_col = symbol_table.getTypeSpecificID(getSymbIDByDerivID(param1)) + 1;
@@ -2622,10 +2607,9 @@ StaticModel::writeParamsDerivativesFile(const string &basename, bool julia) cons
     }
 
   i = 1;
-  for (const auto &it : params_derivatives.find({ 2, 1 })->second)
+  for (const auto &[indices, d2] : params_derivatives.find({ 2, 1 })->second)
     {
-      auto [eq, var1, var2, param] = vectorToTuple<4>(it.first);
-      expr_t d2 = it.second;
+      auto [eq, var1, var2, param] = vectorToTuple<4>(indices);
 
       int var1_col = symbol_table.getTypeSpecificID(getSymbIDByDerivID(var1)) + 1;
       int var2_col = symbol_table.getTypeSpecificID(getSymbIDByDerivID(var2)) + 1;
@@ -2879,7 +2863,7 @@ StaticModel::writeJsonParamsDerivativesFile(ostream &output, bool writeDetails)
                   << R"(, "nparamcols": )" << symbol_table.param_nbr()
                   << R"(, "entries": [)";
   auto &rp = params_derivatives.find({ 0, 1 })->second;
-  for (auto it = rp.begin(); it != rp.end(); it++)
+  for (auto it = rp.begin(); it != rp.end(); ++it)
     {
       if (it != rp.begin())
         jacobian_output << ", ";
@@ -2911,7 +2895,7 @@ StaticModel::writeJsonParamsDerivativesFile(ostream &output, bool writeDetails)
                  << R"(, "nparamcols": )" << symbol_table.param_nbr()
                  << R"(, "entries": [)";
   auto &gp = params_derivatives.find({ 1, 1 })->second;
-  for (auto it = gp.begin(); it != gp.end(); it++)
+  for (auto it = gp.begin(); it != gp.end(); ++it)
     {
       if (it != gp.begin())
         hessian_output << ", ";
diff --git a/src/StaticModel.hh b/src/StaticModel.hh
index 4b359e94fa15f5766c6f823ac962af608909e113..4dc405e97cb383ef5860361b7c3510abf3c8d950 100644
--- a/src/StaticModel.hh
+++ b/src/StaticModel.hh
@@ -192,7 +192,7 @@ public:
   void computingPass(int derivsOrder, int paramsDerivsOrder, const eval_context_t &eval_context, bool no_tmp_terms, bool block, bool bytecode);
 
   //! Adds informations for simulation in a binary file for a block decomposed model
-  void Write_Inf_To_Bin_File_Block(const string &basename, const int &num,
+  void Write_Inf_To_Bin_File_Block(const string &basename, int num,
                                    int &u_count_int, bool &file_open) const;
 
   //! Writes static model file
@@ -211,13 +211,13 @@ public:
   void writeParamsDerivativesFile(const string &basename, bool julia) const;
 
   //! Writes LaTeX file with the equations of the static model
-  void writeLatexFile(const string &basename, const bool write_equation_tags) const;
+  void writeLatexFile(const string &basename, bool write_equation_tags) const;
 
   //! Writes initializations in oo_.steady_state or steady state file for the auxiliary variables
   void writeAuxVarInitval(ostream &output, ExprNodeOutputType output_type) const;
 
   //! Writes definition of the auxiliary variables in a .m or .jl file
-  void writeSetAuxiliaryVariables(const string &basename, const bool julia) const;
+  void writeSetAuxiliaryVariables(const string &basename, bool julia) const;
   void writeAuxVarRecursiveDefinitions(ostream &output, ExprNodeOutputType output_type) const;
   void writeLatexAuxVarRecursiveDefinitions(ostream &output) const;
   void writeJsonAuxVarRecursiveDefinitions(ostream &output) const;
diff --git a/src/SubModel.cc b/src/SubModel.cc
index b3c79ecb3bc8af4cfd5c6a9e2fff2702c49169a2..759312f074378f9405e4701dd7947b3c15f0873f 100644
--- a/src/SubModel.cc
+++ b/src/SubModel.cc
@@ -402,7 +402,7 @@ TrendComponentModelTable::writeJsonOutput(ostream &output) const
 {
   for (const auto &name : names)
     {
-      if (name != *(names.begin()))
+      if (name != *names.begin())
         output << ", ";
       output << R"({"statementName": "trend_component_model",)"
              << R"("model_name": ")" << name << R"(",)"
@@ -541,7 +541,7 @@ VarModelTable::writeJsonOutput(ostream &output) const
 {
   for (const auto &name : names)
     {
-      if (name != *(names.begin()))
+      if (name != *names.begin())
         output << ", ";
       output << R"({"statementName": "var_model",)"
              << R"("model_name": ")" << name << R"(",)";
diff --git a/src/SymbolList.cc b/src/SymbolList.cc
index f8dab968c9b8e1d2423aa3531681d3ed5c50f15c..8c153b277b2787a46a7de74cc70d6fa896d11cb6 100644
--- a/src/SymbolList.cc
+++ b/src/SymbolList.cc
@@ -29,8 +29,7 @@ void
 SymbolList::writeOutput(const string &varname, ostream &output) const
 {
   output << varname << " = {";
-  for (auto it = symbols.begin();
-       it != symbols.end(); ++it)
+  for (auto it = symbols.begin(); it != symbols.end(); ++it)
     {
       if (it != symbols.begin())
         output << ";";
@@ -43,8 +42,7 @@ void
 SymbolList::writeJsonOutput(ostream &output) const
 {
   output << R"("symbol_list": [)";
-  for (auto it = symbols.begin();
-       it != symbols.end(); ++it)
+  for (auto it = symbols.begin(); it != symbols.end(); ++it)
     {
       if (it != symbols.begin())
         output << ",";
diff --git a/src/SymbolTable.cc b/src/SymbolTable.cc
index 0093b5748b2211ceb8620c8f630d78d3174e11f1..dfcf7d9a3bea4aa1275ecabd729bff858ff23202 100644
--- a/src/SymbolTable.cc
+++ b/src/SymbolTable.cc
@@ -43,9 +43,6 @@ AuxVarInfo::AuxVarInfo(int symb_id_arg, AuxVarType type_arg, int orig_symb_id_ar
 {
 }
 
-SymbolTable::SymbolTable()
-= default;
-
 int
 SymbolTable::addSymbol(const string &name, SymbolType type, const string &tex_name, const vector<pair<string, string>> &partition_value) noexcept(false)
 {
@@ -74,7 +71,7 @@ SymbolTable::addSymbol(const string &name, SymbolType type, const string &tex_na
 
   string final_long_name = name;
   bool non_long_name_partition_exists = false;
-  for (auto it : partition_value)
+  for (const auto &it : partition_value)
     if (it.first == "long_name")
       final_long_name = it.second;
     else
@@ -90,7 +87,7 @@ SymbolTable::addSymbol(const string &name, SymbolType type, const string &tex_na
   if (non_long_name_partition_exists)
     {
       map<string, string> pmv;
-      for (auto it : partition_value)
+      for (const auto &it : partition_value)
         pmv[it.first] = it.second;
       partition_value_map[id] = pmv;
     }
@@ -201,12 +198,11 @@ SymbolTable::getPartitionsForType(SymbolType st) const noexcept(false)
   map<string, map<int, string>> partitions;
   for (const auto & it : partition_value_map)
     if (getType(it.first) == st)
-      for (auto it1 = it.second.begin();
-           it1 != it.second.end(); it1++)
+      for (const auto &it1 : it.second)
         {
-          if (partitions.find(it1->first) == partitions.end())
-            partitions[it1->first] = map<int, string> ();
-          partitions[it1->first][it.first] = it1->second;
+          if (partitions.find(it1.first) == partitions.end())
+            partitions[it1.first] = {};
+          partitions[it1.first][it.first] = it1.second;
         }
   return partitions;
 }
@@ -227,24 +223,22 @@ SymbolTable::writeOutput(ostream &output) const noexcept(false)
                << "M_.exo_names_tex(" << id+1 << ") = {'" << getTeXName(exo_ids[id]) << "'};" << endl
                << "M_.exo_names_long(" << id+1 << ") = {'" << getLongName(exo_ids[id]) << "'};" << endl;
       map<string, map<int, string>> partitions = getPartitionsForType(SymbolType::exogenous);
-      for (map<string, map<int, string>>::const_iterator it = partitions.begin();
-           it != partitions.end(); it++)
-        if (it->first != "long_name")
+      for (auto & partition : partitions)
+        if (partition.first != "long_name")
           {
-            map<int, string>::const_iterator it1;
-            output << "M_.exo_partitions." << it->first << " = { ";
+            output << "M_.exo_partitions." << partition.first << " = { ";
             for (int id = 0; id < exo_nbr(); id++)
               {
                 output << "'";
-                it1 = it->second.find(exo_ids[id]);
-                if (it1 != it->second.end())
+                if (auto it1 = partition.second.find(exo_ids[id]);
+                    it1 != partition.second.end())
                   output << it1->second;
                 output << "' ";
               }
             output << "};" << endl;
-            if (it->first == "status")
+            if (partition.first == "status")
               output << "M_ = set_observed_exogenous_variables(M_);" << endl;
-            if (it->first == "used")
+            if (partition.first == "used")
               output << "M_ = set_exogenous_variables_for_simulation(M_);" << endl;
           }
     }
@@ -266,17 +260,15 @@ SymbolTable::writeOutput(ostream &output) const noexcept(false)
                << "M_.exo_det_names_long(" << id+1 << ") = {'" << getLongName(exo_det_ids[id]) << "'};" << endl;
       output << "M_.exo_det_partitions = struct();" << endl;
       map<string, map<int, string>> partitions = getPartitionsForType(SymbolType::exogenousDet);
-      for (map<string, map<int, string>>::const_iterator it = partitions.begin();
-           it != partitions.end(); it++)
-        if (it->first != "long_name")
+      for (auto & partition : partitions)
+        if (partition.first != "long_name")
           {
-            map<int, string>::const_iterator it1;
-            output << "M_.exo_det_partitions." << it->first << " = { ";
+            output << "M_.exo_det_partitions." << partition.first << " = { ";
             for (int id = 0; id < exo_det_nbr(); id++)
               {
                 output << "'";
-                it1 = it->second.find(exo_det_ids[id]);
-                if (it1 != it->second.end())
+                if (auto it1 = partition.second.find(exo_det_ids[id]);
+                    it1 != partition.second.end())
                   output << it1->second;
                 output << "' ";
               }
@@ -295,17 +287,15 @@ SymbolTable::writeOutput(ostream &output) const noexcept(false)
                << "M_.endo_names_long(" << id+1 << ") = {'" << getLongName(endo_ids[id]) << "'};" << endl;
       output << "M_.endo_partitions = struct();" << endl;
       map<string, map<int, string>> partitions = getPartitionsForType(SymbolType::endogenous);
-      for (map<string, map<int, string>>::const_iterator it = partitions.begin();
-           it != partitions.end(); it++)
-        if (it->first != "long_name")
+      for (auto & partition : partitions)
+        if (partition.first != "long_name")
           {
-            map<int, string>::const_iterator it1;
-            output << "M_.endo_partitions." << it->first << " = { ";
+            output << "M_.endo_partitions." << partition.first << " = { ";
             for (int id = 0; id < endo_nbr(); id++)
               {
                 output << "'";
-                it1 = it->second.find(endo_ids[id]);
-                if (it1 != it->second.end())
+                if (auto it1 = partition.second.find(endo_ids[id]);
+                    it1 != partition.second.end())
                   output << it1->second;
                 output << "' ";
               }
@@ -328,17 +318,15 @@ SymbolTable::writeOutput(ostream &output) const noexcept(false)
         }
       output << "M_.param_partitions = struct();" << endl;
       map<string, map<int, string>> partitions = getPartitionsForType(SymbolType::parameter);
-      for (map<string, map<int, string>>::const_iterator it = partitions.begin();
-           it != partitions.end(); it++)
-        if (it->first != "long_name")
+      for (auto & partition : partitions)
+        if (partition.first != "long_name")
           {
-            map<int, string>::const_iterator it1;
-            output << "M_.param_partitions." << it->first << " = { ";
+            output << "M_.param_partitions." << partition.first << " = { ";
             for (int id = 0; id < param_nbr(); id++)
               {
                 output << "'";
-                it1 = it->second.find(param_ids[id]);
-                if (it1 != it->second.end())
+                if (auto it1 = partition.second.find(param_ids[id]);
+                    it1 != partition.second.end())
                   output << it1->second;
                 output << "' ";
               }
@@ -418,8 +406,7 @@ SymbolTable::writeOutput(ostream &output) const noexcept(false)
     {
       int ic = 1;
       output << "options_.varobs = cell(" << observedVariablesNbr() << ", 1);" << endl;
-      for (auto it = varobs.begin();
-           it != varobs.end(); it++, ic++)
+      for (auto it = varobs.begin(); it != varobs.end(); ++it, ic++)
         output << "options_.varobs(" << ic << ")  = {'" << getName(*it) << "'};" << endl;
 
       output << "options_.varobs_id = [ ";
@@ -432,8 +419,7 @@ SymbolTable::writeOutput(ostream &output) const noexcept(false)
     {
       int ic = 1;
       output << "options_.varexobs = cell(1);" << endl;
-      for (auto it = varexobs.begin();
-           it != varexobs.end(); it++, ic++)
+      for (auto it = varexobs.begin(); it != varexobs.end(); ++it, ic++)
         output << "options_.varexobs(" << ic << ")  = {'" << getName(*it) << "'};" << endl;
 
       output << "options_.varexobs_id = [ ";
@@ -757,13 +743,11 @@ SymbolTable::getAuxiliaryVarsExprNode(int symb_id) const noexcept(false)
 {
   for (const auto & aux_var : aux_vars)
     if (aux_var.get_symb_id() == symb_id)
-      {
-        expr_t expr_node = aux_var.get_expr_node();
-        if (expr_node != nullptr)
-          return expr_node;
-        else
-          throw SearchFailedException(symb_id);
-      }
+      if (expr_t expr_node = aux_var.get_expr_node();
+          expr_node)
+        return expr_node;
+      else
+        throw SearchFailedException(symb_id);
   throw SearchFailedException(symb_id);
 }
 
@@ -810,7 +794,7 @@ SymbolTable::observedVariablesNbr() const
 bool
 SymbolTable::isObservedVariable(int symb_id) const
 {
-  return (find(varobs.begin(), varobs.end(), symb_id) != varobs.end());
+  return find(varobs.begin(), varobs.end(), symb_id) != varobs.end();
 }
 
 int
@@ -838,7 +822,7 @@ SymbolTable::observedExogenousVariablesNbr() const
 bool
 SymbolTable::isObservedExogenousVariable(int symb_id) const
 {
-  return (find(varexobs.begin(), varexobs.end(), symb_id) != varexobs.end());
+  return find(varexobs.begin(), varexobs.end(), symb_id) != varexobs.end();
 }
 
 int
diff --git a/src/SymbolTable.hh b/src/SymbolTable.hh
index 94830f9734c99c805751c4f3b87fb23a17e54c8c..2552813a3395511dc030ae7703e11e9bab4d9969 100644
--- a/src/SymbolTable.hh
+++ b/src/SymbolTable.hh
@@ -167,7 +167,6 @@ private:
   vector<int> varexobs;
 
 public:
-  SymbolTable();
   //! Thrown when trying to access an unknown symbol (by name)
   class UnknownSymbolNameException
   {
@@ -425,8 +424,7 @@ SymbolTable::validateSymbID(int symb_id) const noexcept(false)
 inline bool
 SymbolTable::exists(const string &name) const
 {
-  auto iter = symbol_table.find(name);
-  return (iter != symbol_table.end());
+  return symbol_table.find(name) != symbol_table.end();
 }
 
 inline string
@@ -466,8 +464,8 @@ SymbolTable::getType(const string &name) const noexcept(false)
 inline int
 SymbolTable::getID(const string &name) const noexcept(false)
 {
-  auto iter = symbol_table.find(name);
-  if (iter != symbol_table.end())
+  if (auto iter = symbol_table.find(name);
+      iter != symbol_table.end())
     return iter->second;
   else
     throw UnknownSymbolNameException(name);
@@ -535,7 +533,7 @@ SymbolTable::maxID()
 inline int
 SymbolTable::orig_endo_nbr() const noexcept(false)
 {
-  return (endo_nbr() - aux_vars.size());
+  return endo_nbr() - aux_vars.size();
 }
 
 #endif
diff --git a/src/macro/Driver.cc b/src/macro/Driver.cc
index e1f18cdc4fffe0766ffaf6142a06bdac86566ec7..b1ccc5cc835f5f548cd1071f89bd3310fb42bd78 100644
--- a/src/macro/Driver.cc
+++ b/src/macro/Driver.cc
@@ -44,7 +44,7 @@ Driver::parse(const string &file_arg, const string &basename_arg, istream &modfi
               // If the input is an array. Issue #1578
               command_line_defines_with_endl << "@#define " << var << " = " << val << endl;
             else
-              command_line_defines_with_endl << "@#define " << var << " = \"" << val << "\"" << endl;
+              command_line_defines_with_endl << "@#define " << var << R"( = ")" << val << '"' << endl;
           }
       Driver m(env, true);
       istream is(command_line_defines_with_endl.rdbuf());