diff --git a/src/DynamicModel.cc b/src/DynamicModel.cc
index c5d3ad744662a463e993093f5c0e7e3e1a5cbddc..2baf93c7c503831ddfa2f1bb239e0b3bb55dbff1 100644
--- a/src/DynamicModel.cc
+++ b/src/DynamicModel.cc
@@ -668,19 +668,19 @@ DynamicModel::writeDynamicMFile(const string &basename) const
   ostringstream init_output, end_output;
   init_output << "residual = zeros(" << equations.size() << ", 1);";
   writeDynamicMFileHelper(basename, "dynamic_resid", "residual", "dynamic_resid_tt",
-                          temporary_terms_mlv.size() + temporary_terms_derivatives[0].size(),
+                          temporary_terms_derivatives[0].size(),
                           "", init_output, end_output, d_output[0], tt_output[0]);
 
   init_output.str("");
   init_output << "g1 = zeros(" << equations.size() << ", " << getJacobianColsNbr() << ");";
   writeDynamicMFileHelper(basename, "dynamic_g1", "g1", "dynamic_g1_tt",
-                          temporary_terms_mlv.size() + temporary_terms_derivatives[0].size() + temporary_terms_derivatives[1].size(),
+                          temporary_terms_derivatives[0].size() + temporary_terms_derivatives[1].size(),
                           "dynamic_resid_tt", init_output, end_output, d_output[1], tt_output[1]);
   writeDynamicMWrapperFunction(basename, "g1");
 
   // For order ≥ 2
   int ncols{getJacobianColsNbr()};
-  int ntt{static_cast<int>(temporary_terms_mlv.size() + temporary_terms_derivatives[0].size() + temporary_terms_derivatives[1].size())};
+  int ntt { static_cast<int>(temporary_terms_derivatives[0].size() + temporary_terms_derivatives[1].size()) };
   for (size_t i{2}; i < derivatives.size(); i++)
     {
       ncols *= getJacobianColsNbr();
@@ -772,7 +772,7 @@ DynamicModel::writeDynamicJuliaFile(const string &basename) const
 
   // Write the number of temporary terms
   output << "tmp_nbr = zeros(Int,4)" << endl
-         << "tmp_nbr[1] = " << temporary_terms_mlv.size() + temporary_terms_derivatives[0].size() << "# Number of temporary terms for the residuals" << endl
+         << "tmp_nbr[1] = " << temporary_terms_derivatives[0].size() << "# Number of temporary terms for the residuals" << endl
          << "tmp_nbr[2] = " << temporary_terms_derivatives[1].size() << "# Number of temporary terms for g1 (jacobian)" << endl
          << "tmp_nbr[3] = " << temporary_terms_derivatives[2].size() << "# Number of temporary terms for g2 (hessian)" << endl
          << "tmp_nbr[4] = " << temporary_terms_derivatives[3].size() << "# Number of temporary terms for g3 (third order derivates)" << endl << endl;
@@ -791,7 +791,7 @@ DynamicModel::writeDynamicJuliaFile(const string &basename) const
   output << "function dynamicResid!(T::Vector{<: Real}, residual::AbstractVector{<: Real}," << endl
          << "                       y::Vector{<: Real}, x::Matrix{<: Real}, "
          << "params::Vector{<: Real}, steady_state::Vector{<: Real}, it_::Int, T_flag::Bool)" << endl
-         << "    @assert length(T) >= " << temporary_terms_mlv.size() + temporary_terms_derivatives[0].size() << endl
+         << "    @assert length(T) >= " << temporary_terms_derivatives[0].size() << endl
          << "    @assert length(residual) == " << equations.size() << endl
          << "    @assert length(y)+size(x, 2) == " << getJacobianColsNbr() << endl
          << "    @assert length(params) == " << symbol_table.param_nbr() << endl
@@ -820,7 +820,7 @@ DynamicModel::writeDynamicJuliaFile(const string &basename) const
          << "                    y::Vector{<: Real}, x::Matrix{<: Real}, "
          << "params::Vector{<: Real}, steady_state::Vector{<: Real}, it_::Int, T_flag::Bool)" << endl
          << "    @assert length(T) >= "
-         << temporary_terms_mlv.size() + temporary_terms_derivatives[0].size() + temporary_terms_derivatives[1].size() << endl
+         << temporary_terms_derivatives[0].size() + temporary_terms_derivatives[1].size() << endl
          << "    @assert size(g1) == (" << equations.size() << ", " << getJacobianColsNbr() << ")" << endl
          << "    @assert length(y)+size(x, 2) == " << getJacobianColsNbr() << endl
          << "    @assert length(params) == " << symbol_table.param_nbr() << endl
@@ -850,7 +850,7 @@ DynamicModel::writeDynamicJuliaFile(const string &basename) const
   output << "function dynamicG2!(T::Vector{<: Real}, g2::Matrix{<: Real}," << endl
          << "                    y::Vector{<: Real}, x::Matrix{<: Real}, "
          << "params::Vector{<: Real}, steady_state::Vector{<: Real}, it_::Int, T_flag::Bool)" << endl
-         << "    @assert length(T) >= " << temporary_terms_mlv.size() + temporary_terms_derivatives[0].size() + temporary_terms_derivatives[1].size() + temporary_terms_derivatives[2].size() << endl
+         << "    @assert length(T) >= " << temporary_terms_derivatives[0].size() + temporary_terms_derivatives[1].size() + temporary_terms_derivatives[2].size() << endl
          << "    @assert size(g2) == (" << equations.size() << ", " << hessianColsNbr << ")" << endl
          << "    @assert length(y)+size(x, 2) == " << getJacobianColsNbr() << endl
          << "    @assert length(params) == " << symbol_table.param_nbr() << endl
@@ -881,7 +881,7 @@ DynamicModel::writeDynamicJuliaFile(const string &basename) const
          << "                    y::Vector{<: Real}, x::Matrix{<: Real}, "
          << "params::Vector{<: Real}, steady_state::Vector{<: Real}, it_::Int, T_flag::Bool)" << endl
          << "    @assert length(T) >= "
-         << temporary_terms_mlv.size() + temporary_terms_derivatives[0].size() + temporary_terms_derivatives[1].size() + temporary_terms_derivatives[2].size() + temporary_terms_derivatives[3].size() << endl
+         << temporary_terms_derivatives[0].size() + temporary_terms_derivatives[1].size() + temporary_terms_derivatives[2].size() + temporary_terms_derivatives[3].size() << endl
          << "    @assert size(g3) == (" << equations.size() << ", " << ncols << ")" << endl
          << "    @assert length(y)+size(x, 2) == " << getJacobianColsNbr() << endl
          << "    @assert length(params) == " << symbol_table.param_nbr() << endl
@@ -944,7 +944,7 @@ DynamicModel::writeDynamicCFile(const string &basename) const
 {
   string filename = basename + "/model/src/dynamic.c";
 
-  int ntt{static_cast<int>(temporary_terms_mlv.size() + temporary_terms_derivatives[0].size() + temporary_terms_derivatives[1].size() + temporary_terms_derivatives[2].size() + temporary_terms_derivatives[3].size())};
+  int ntt { static_cast<int>(temporary_terms_derivatives[0].size() + temporary_terms_derivatives[1].size() + temporary_terms_derivatives[2].size() + temporary_terms_derivatives[3].size()) };
 
   ofstream output{filename, ios::out | ios::binary};
   if (!output.is_open())
@@ -1370,7 +1370,7 @@ DynamicModel::writeDynamicMCompatFile(const string &basename) const
       cerr << "Error: Can't open file " << filename << " for writing" << endl;
       exit(EXIT_FAILURE);
     }
-  int ntt = temporary_terms_mlv.size() + temporary_terms_derivatives[0].size() + temporary_terms_derivatives[1].size() + temporary_terms_derivatives[2].size() + temporary_terms_derivatives[3].size();
+  int ntt { static_cast<int>(temporary_terms_derivatives[0].size() + temporary_terms_derivatives[1].size() + temporary_terms_derivatives[2].size() + temporary_terms_derivatives[3].size()) };
 
   output << "function [residual, g1, g2, g3] = dynamic(y, x, params, steady_state, it_)" << endl
          << "    T = NaN(" << ntt << ", 1);" << endl
@@ -2038,18 +2038,10 @@ DynamicModel::writeDriverOutput(ostream &output, const string &basename, bool bl
          << "M_.nspred   = " << npred+nboth   << ";" << endl
          << "M_.ndynamic   = " << npred+nboth+nfwrd << ";" << endl
          << "M_.dynamic_tmp_nbr = [";
-  for (size_t i = 0; i < temporary_terms_derivatives.size(); i++)
-    output << temporary_terms_derivatives[i].size() + (i == 0 ? temporary_terms_mlv.size() : 0) << "; ";
+  for (const auto &tts : temporary_terms_derivatives)
+    output << tts.size() << "; ";
   output << "];" << endl;
 
-  /* Write mapping between model local variables and indices in the temporary
-     terms vector (dynare#1722) */
-  output << "M_.model_local_variables_dynamic_tt_idxs = {" << endl;
-  for (auto [mlv, value] : temporary_terms_mlv)
-    output << "  '" << symbol_table.getName(mlv->symb_id) << "', "
-           << temporary_terms_idxs.at(mlv)+1 << ';' << endl;
-  output << "};" << endl;
-
   // Write equation tags
   equation_tags.writeOutput(output);
 
@@ -3291,8 +3283,6 @@ DynamicModel::computingPass(bool jacobianExo, int derivsOrder, int paramsDerivsO
 
   computeTemporaryTerms(!use_dll, no_tmp_terms);
 
-  /* Must be called after computeTemporaryTerms(), because it depends on
-     temporary_terms_mlv to be filled */
   if (paramsDerivsOrder > 0 && !no_tmp_terms)
     computeParamsDerivativesTemporaryTerms();
 
@@ -4708,8 +4698,6 @@ DynamicModel::isChecksumMatching(const string &basename) const
 
   deriv_node_temp_terms_t tef_terms;
   temporary_terms_t temp_term_union;
-  writeModelLocalVariableTemporaryTerms<buffer_type>(temp_term_union, temporary_terms_idxs,
-                                                     buffer, tef_terms);
 
   writeTemporaryTerms<buffer_type>(temporary_terms_derivatives[0],
                                    temp_term_union, temporary_terms_idxs,
diff --git a/src/ModelTree.cc b/src/ModelTree.cc
index 735641d4a14f90eb3271680c66651f7658f6f50f..11ec1a0d69fed12655a58565f7f164581542f0c0 100644
--- a/src/ModelTree.cc
+++ b/src/ModelTree.cc
@@ -70,8 +70,6 @@ ModelTree::copyHelper(const ModelTree &m)
                                    };
 
   // Temporary terms
-  for (const auto &it : m.temporary_terms_mlv)
-    temporary_terms_mlv.emplace(dynamic_cast<VariableNode *>(f(it.first)), f(it.second));
   for (const auto &it : m.temporary_terms_derivatives)
     temporary_terms_derivatives.push_back(convert_temporary_terms_t(it));
   for (const auto &it : m.temporary_terms_idxs)
@@ -170,7 +168,6 @@ ModelTree::operator=(const ModelTree &m)
   derivatives.clear();
   params_derivatives.clear();
 
-  temporary_terms_mlv.clear();
   temporary_terms_derivatives.clear();
   params_derivs_temporary_terms.clear();
   params_derivs_temporary_terms_idxs.clear();
@@ -921,20 +918,15 @@ ModelTree::computeDerivatives(int order, const set<int> &vars)
 void
 ModelTree::computeTemporaryTerms(bool is_matlab, bool no_tmp_terms)
 {
-  /* Collect all model local variables appearing in equations (and only those,
-     because printing unused model local variables can lead to a crash,
-     see Dynare/dynare#101).
-     Then store them in a dedicated structure (temporary_terms_mlv), that will
-     be treated as the rest of temporary terms. */
-  temporary_terms_mlv.clear();
-  set<int> used_local_vars;
-  for (auto &equation : equations)
-    equation->collectVariables(SymbolType::modelLocalVariable, used_local_vars);
-  for (int used_local_var : used_local_vars)
-    {
-      VariableNode *v = AddVariable(used_local_var);
-      temporary_terms_mlv[v] = local_variables_table.find(used_local_var)->second;
-    }
+  /* Ensure that we don’t have any model-local variable in the model at this
+     point (we used to treat them as temporary terms) */
+  assert([&]
+  {
+    set<int> used_local_vars;
+    for (auto &equation : equations)
+      equation->collectVariables(SymbolType::modelLocalVariable, used_local_vars);
+    return used_local_vars.empty();
+  }());
 
   // Compute the temporary terms in equations and derivatives
   map<pair<int, int>, temporary_terms_t> temp_terms_map;
@@ -968,10 +960,7 @@ ModelTree::computeTemporaryTerms(bool is_matlab, bool no_tmp_terms)
     temporary_terms_derivatives[order] = move(temp_terms_map[{ 0, order }]);
 
   // Compute indices in MATLAB/Julia vector
-  int idx = 0;
-  for (auto [mlv, value] : temporary_terms_mlv)
-    temporary_terms_idxs[mlv] = idx++;
-  for (int order = 0; order < static_cast<int>(derivatives.size()); order++)
+  for (int order {0}, idx {0}; order < static_cast<int>(derivatives.size()); order++)
     for (auto it : temporary_terms_derivatives[order])
       temporary_terms_idxs[it] = idx++;
 }
@@ -1496,10 +1485,8 @@ ModelTree::computeParamsDerivativesTemporaryTerms()
       d->computeTemporaryTerms(order, params_derivs_temporary_terms,
                                reference_count, true);
 
-  int idx = 0;
-  for (auto &[mlv, value] : temporary_terms_mlv)
-    params_derivs_temporary_terms_idxs[mlv] = idx++;
-  for (const auto &[order, tts] : params_derivs_temporary_terms)
+  for (int idx {0};
+       const auto &[order, tts] : params_derivs_temporary_terms)
     for (const auto &tt : tts)
       params_derivs_temporary_terms_idxs[tt] = idx++;
 }
diff --git a/src/ModelTree.hh b/src/ModelTree.hh
index 2126c45d3a866be2e9261ad055f6f039780c6659..84e2b085cfa3410acdc713bdb0d45b0f53cc02da 100644
--- a/src/ModelTree.hh
+++ b/src/ModelTree.hh
@@ -125,10 +125,6 @@ protected:
   then the IDs of parameters (in non-decreasing order)*/
   map<pair<int,int>, map<vector<int>, expr_t>> params_derivatives;
 
-  //! Used model local variables, that will be treated as temporary terms
-  /*! See the comments in ModelTree::computeTemporaryTerms() */
-  map<VariableNode *, expr_t, ExprNodeLess> temporary_terms_mlv;
-
   //! Temporary terms for residuals and derivatives
   /*! Index 0 is temp. terms of residuals, index 1 for first derivatives, ... */
   vector<temporary_terms_t> temporary_terms_derivatives;
@@ -259,10 +255,6 @@ protected:
   //! Tests if string contains more than 32 nested parens, Issue #1201
   bool testNestedParenthesis(const string &str) const;
 
-  template<ExprNodeOutputType output_type>
-  void writeModelLocalVariableTemporaryTerms(temporary_terms_t &temp_term_union,
-                                             const temporary_terms_idxs_t &tt_idxs,
-                                             ostream &output, deriv_node_temp_terms_t &tef_terms) const;
   //! Writes model equations
   template<ExprNodeOutputType output_type>
   void writeModelEquations(ostream &output, const temporary_terms_t &temporary_terms) const;
@@ -594,38 +586,6 @@ ModelTree::writeTemporaryTerms(const temporary_terms_t &tt,
     }
 }
 
-template<ExprNodeOutputType output_type>
-void
-ModelTree::writeModelLocalVariableTemporaryTerms(temporary_terms_t &temp_term_union,
-                                                 const temporary_terms_idxs_t &tt_idxs,
-                                                 ostream &output, deriv_node_temp_terms_t &tef_terms) const
-{
-  temporary_terms_t tto;
-  for (const auto &[mlv, value] : temporary_terms_mlv)
-    tto.insert(mlv);
-
-  for (const auto &[mlv, value] : temporary_terms_mlv)
-    {
-      value->writeExternalFunctionOutput(output, output_type, temp_term_union, tt_idxs, tef_terms);
-
-      if constexpr(isJuliaOutput(output_type))
-        output << "    const ";
-
-      mlv->writeOutput(output, output_type, tto, tt_idxs, tef_terms);
-      output << " = ";
-      value->writeOutput(output, output_type, temp_term_union, tt_idxs, tef_terms);
-
-      if constexpr(isCOutput(output_type) || isMatlabOutput(output_type))
-        output << ";";
-      output << endl;
-
-      /* We put in temp_term_union the VariableNode corresponding to the MLV,
-         not its definition, so that when equations use the MLV,
-         T(XXX) is printed instead of the MLV name */
-      temp_term_union.insert(mlv);
-    }
-}
-
 template<ExprNodeOutputType output_type>
 void
 ModelTree::writeModelEquations(ostream &output, const temporary_terms_t &temporary_terms) const
@@ -692,9 +652,6 @@ ModelTree::writeModelFileHelper() const
   deriv_node_temp_terms_t tef_terms;
   temporary_terms_t temp_term_union;
 
-  writeModelLocalVariableTemporaryTerms<output_type>(temp_term_union, temporary_terms_idxs,
-                                                     tt_output[0], tef_terms);
-
   writeTemporaryTerms<output_type>(temporary_terms_derivatives[0], temp_term_union,
                                    temporary_terms_idxs, tt_output[0], tef_terms);
 
@@ -921,9 +878,6 @@ ModelTree::writeParamsDerivativesFileHelper() const
   temporary_terms_t temp_term_union;
   deriv_node_temp_terms_t tef_terms;
 
-  writeModelLocalVariableTemporaryTerms<output_type>(temp_term_union,
-                                                     params_derivs_temporary_terms_idxs,
-                                                     tt_output, tef_terms);
   for (const auto &[order, tts] : params_derivs_temporary_terms)
     writeTemporaryTerms<output_type>(tts, temp_term_union, params_derivs_temporary_terms_idxs,
                                      tt_output, tef_terms);
diff --git a/src/StaticModel.cc b/src/StaticModel.cc
index 7f7d3449703eb0755cd4c607ef8d4887da0be13d..f3648d534d23998e957a9c6c713c5e801cf5fcfa 100644
--- a/src/StaticModel.cc
+++ b/src/StaticModel.cc
@@ -369,8 +369,6 @@ StaticModel::computingPass(int derivsOrder, int paramsDerivsOrder, const eval_co
 
   computeTemporaryTerms(true, no_tmp_terms);
 
-  /* Must be called after computeTemporaryTerms(), because it depends on
-     temporary_terms_mlv to be filled */
   if (paramsDerivsOrder > 0 && !no_tmp_terms)
     computeParamsDerivativesTemporaryTerms();
 
@@ -412,7 +410,7 @@ StaticModel::writeStaticMFile(const string &basename) const
              << "  residual = real(residual)+imag(residual).^2;" << endl
              << "end";
   writeStaticMFileHelper(basename, "static_resid", "residual", "static_resid_tt",
-                         temporary_terms_mlv.size() + temporary_terms_derivatives[0].size(),
+                         temporary_terms_derivatives[0].size(),
                          "", init_output, end_output,
                          d_output[0], tt_output[0]);
 
@@ -423,7 +421,7 @@ StaticModel::writeStaticMFile(const string &basename) const
              << "    g1 = real(g1)+2*imag(g1);" << endl
              << "end";
   writeStaticMFileHelper(basename, "static_g1", "g1", "static_g1_tt",
-                         temporary_terms_mlv.size() + temporary_terms_derivatives[0].size() + temporary_terms_derivatives[1].size(),
+                         temporary_terms_derivatives[0].size() + temporary_terms_derivatives[1].size(),
                          "static_resid_tt",
                          init_output, end_output,
                          d_output[1], tt_output[1]);
@@ -431,7 +429,7 @@ StaticModel::writeStaticMFile(const string &basename) const
 
   // For order ≥ 2
   int ncols{symbol_table.endo_nbr()};
-  int ntt{static_cast<int>(temporary_terms_mlv.size() + temporary_terms_derivatives[0].size() + temporary_terms_derivatives[1].size())};
+  int ntt { static_cast<int>(temporary_terms_derivatives[0].size() + temporary_terms_derivatives[1].size()) };
   for (size_t i{2}; i < derivatives.size(); i++)
     {
       ncols *= symbol_table.endo_nbr();
@@ -603,7 +601,7 @@ StaticModel::writeStaticMCompatFile(const string &basename) const
       cerr << "Error: Can't open file " << filename << " for writing" << endl;
       exit(EXIT_FAILURE);
     }
-  int ntt = temporary_terms_mlv.size() + temporary_terms_derivatives[0].size() + temporary_terms_derivatives[1].size() + temporary_terms_derivatives[2].size() + temporary_terms_derivatives[3].size();
+  int ntt { static_cast<int>(temporary_terms_derivatives[0].size() + temporary_terms_derivatives[1].size() + temporary_terms_derivatives[2].size() + temporary_terms_derivatives[3].size()) };
 
   output << "function [residual, g1, g2, g3] = static(y, x, params)" << endl
          << "    T = NaN(" << ntt << ", 1);" << endl
@@ -627,7 +625,7 @@ StaticModel::writeStaticCFile(const string &basename) const
   // Writing comments and function definition command
   string filename{basename + "/model/src/static.c"};
 
-  int ntt{static_cast<int>(temporary_terms_mlv.size() + temporary_terms_derivatives[0].size() + temporary_terms_derivatives[1].size() + temporary_terms_derivatives[2].size() + temporary_terms_derivatives[3].size())};
+  int ntt { static_cast<int>(temporary_terms_derivatives[0].size() + temporary_terms_derivatives[1].size() + temporary_terms_derivatives[2].size() + temporary_terms_derivatives[3].size()) };
 
   ofstream output{filename, ios::out | ios::binary};
   if (!output.is_open())
@@ -791,7 +789,7 @@ StaticModel::writeStaticJuliaFile(const string &basename) const
 
   // Write the number of temporary terms
   output << "tmp_nbr = zeros(Int,4)" << endl
-         << "tmp_nbr[1] = " << temporary_terms_mlv.size() + temporary_terms_derivatives[0].size() << "# Number of temporary terms for the residuals" << endl
+         << "tmp_nbr[1] = " << temporary_terms_derivatives[0].size() << "# Number of temporary terms for the residuals" << endl
          << "tmp_nbr[2] = " << temporary_terms_derivatives[1].size() << "# Number of temporary terms for g1 (jacobian)" << endl
          << "tmp_nbr[3] = " << temporary_terms_derivatives[2].size() << "# Number of temporary terms for g2 (hessian)" << endl
          << "tmp_nbr[4] = " << temporary_terms_derivatives[3].size() << "# Number of temporary terms for g3 (third order derivates)" << endl << endl;
@@ -799,7 +797,7 @@ StaticModel::writeStaticJuliaFile(const string &basename) const
   // staticResidTT!
   output << "function staticResidTT!(T::Vector{<: Real}," << endl
          << "                        y::Vector{<: Real}, x::Vector{<: Real}, params::Vector{<: Real})" << endl
-         << "    @assert length(T) >= " << temporary_terms_mlv.size() + temporary_terms_derivatives[0].size()  << endl
+         << "    @assert length(T) >= " << temporary_terms_derivatives[0].size()  << endl
          << "    @inbounds begin" << endl
          << tt_output[0].str()
 	 << "    end" << endl
@@ -841,7 +839,7 @@ StaticModel::writeStaticJuliaFile(const string &basename) const
   output << "function staticG1!(T::Vector{<: Real}, g1::Matrix{<: Real}," << endl
          << "                   y::Vector{<: Real}, x::Vector{<: Real}, params::Vector{<: Real}, T1_flag::Bool, T0_flag::Bool)" << endl
          << "    @assert length(T) >= "
-         << temporary_terms_mlv.size() + temporary_terms_derivatives[0].size() + temporary_terms_derivatives[1].size() << endl
+         << temporary_terms_derivatives[0].size() + temporary_terms_derivatives[1].size() << endl
          << "    @assert size(g1) == (" << equations.size() << ", " << symbol_table.endo_nbr() << ")" << endl
          << "    @assert length(y) == " << symbol_table.endo_nbr() << endl
          << "    @assert length(x) == " << symbol_table.exo_nbr() << endl
@@ -876,7 +874,7 @@ StaticModel::writeStaticJuliaFile(const string &basename) const
   output << "function staticG2!(T::Vector{<: Real}, g2::Matrix{<: Real}," << endl
          << "                   y::Vector{<: Real}, x::Vector{<: Real}, params::Vector{<: Real}, T2_flag::Bool, T1_flag::Bool, T0_flag::Bool)" << endl
          << "    @assert length(T) >= "
-         << temporary_terms_mlv.size() + temporary_terms_derivatives[0].size() + temporary_terms_derivatives[1].size() + temporary_terms_derivatives[2].size() << endl
+         << temporary_terms_derivatives[0].size() + temporary_terms_derivatives[1].size() + temporary_terms_derivatives[2].size() << endl
          << "    @assert size(g2) == (" << equations.size() << ", " << hessianColsNbr << ")" << endl
          << "    @assert length(y) == " << symbol_table.endo_nbr() << endl
          << "    @assert length(x) == " << symbol_table.exo_nbr() << endl
@@ -908,7 +906,7 @@ StaticModel::writeStaticJuliaFile(const string &basename) const
   output << "function staticG3!(T::Vector{<: Real}, g3::Matrix{<: Real}," << endl
          << "                   y::Vector{<: Real}, x::Vector{<: Real}, params::Vector{<: Real}, T3_flag::Bool, T2_flag::Bool, T1_flag::Bool, T0_flag::Bool)" << endl
          << "    @assert length(T) >= "
-         << temporary_terms_mlv.size() + temporary_terms_derivatives[0].size() + temporary_terms_derivatives[1].size() + temporary_terms_derivatives[2].size() + temporary_terms_derivatives[3].size() << endl
+         << temporary_terms_derivatives[0].size() + temporary_terms_derivatives[1].size() + temporary_terms_derivatives[2].size() + temporary_terms_derivatives[3].size() << endl
          << "    @assert size(g3) == (" << equations.size() << ", " << ncols << ")" << endl
          << "    @assert length(y) == " << symbol_table.endo_nbr() << endl
          << "    @assert length(x) == " << symbol_table.exo_nbr() << endl
@@ -1138,14 +1136,6 @@ StaticModel::writeDriverOutput(ostream &output, bool block) const
     output << temporary_terms_derivative.size() << "; ";
   output << "];" << endl;
 
-  /* Write mapping between model local variables and indices in the temporary
-     terms vector (dynare#1722) */
-  output << "M_.model_local_variables_static_tt_idxs = {" << endl;
-  for (auto [mlv, value] : temporary_terms_mlv)
-    output << "  '" << symbol_table.getName(mlv->symb_id) << "', "
-           << temporary_terms_idxs.at(mlv)+1 << ';' << endl;
-  output << "};" << endl;
-
   if (block)
     writeBlockDriverOutput(output);
 }