diff --git a/src/DynamicModel.cc b/src/DynamicModel.cc
index f146635592d018d61b298cabe5a64fa682cdb9d4..2b821709d3f967ad9c5c6dccf81d205239123b5f 100644
--- a/src/DynamicModel.cc
+++ b/src/DynamicModel.cc
@@ -306,8 +306,6 @@ DynamicModel::computeTemporaryTermsOrdered()
               expr_t id = get<3>(it);
               id->computeTemporaryTerms(reference_count, temporary_terms, first_occurence, block, v_temporary_terms, block_size-1);
             }
-          for (const auto &it : derivative_endo[block])
-            it.second->computeTemporaryTerms(reference_count, temporary_terms, first_occurence, block, v_temporary_terms, block_size-1);
           for (const auto &it : derivative_other_endo[block])
             it.second->computeTemporaryTerms(reference_count, temporary_terms, first_occurence, block, v_temporary_terms, block_size-1);
           v_temporary_terms_inuse[block] = {};
@@ -337,8 +335,6 @@ DynamicModel::computeTemporaryTermsOrdered()
               expr_t id = get<3>(it);
               id->computeTemporaryTerms(reference_count, temporary_terms, first_occurence, block, v_temporary_terms, block_size-1);
             }
-          for (const auto &it : derivative_endo[block])
-            it.second->computeTemporaryTerms(reference_count, temporary_terms, first_occurence, block, v_temporary_terms, block_size-1);
           for (const auto &it : derivative_other_endo[block])
             it.second->computeTemporaryTerms(reference_count, temporary_terms, first_occurence, block, v_temporary_terms, block_size-1);
         }
@@ -364,8 +360,6 @@ DynamicModel::computeTemporaryTermsOrdered()
               expr_t id = get<3>(it);
               id->collectTemporary_terms(temporary_terms, temporary_terms_in_use, block);
             }
-          for (const auto &it : derivative_endo[block])
-            it.second->collectTemporary_terms(temporary_terms, temporary_terms_in_use, block);
           for (const auto &it : derivative_other_endo[block])
             it.second->collectTemporary_terms(temporary_terms, temporary_terms_in_use, block);
           for (const auto &it : derivative_exo[block])
@@ -415,7 +409,7 @@ DynamicModel::writeModelEquationsOrdered_M(const string &basename) const
       //recursive_variables.clear();
       feedback_variables.clear();
       //For a block composed of a single equation determines wether we have to evaluate or to solve the equation
-      nze = derivative_endo[block].size();
+      nze = blocks_derivatives[block].size();
       nze_other_endo = derivative_other_endo[block].size();
       nze_exo = derivative_exo[block].size();
       nze_exo_det = derivative_exo_det[block].size();
diff --git a/src/StaticModel.cc b/src/StaticModel.cc
index a70c95157d26d15a661e18a73e1bd7aaf1f6d8c4..99ceef31c283668e4f8dfc25a60ad64cc3450477 100644
--- a/src/StaticModel.cc
+++ b/src/StaticModel.cc
@@ -410,7 +410,7 @@ StaticModel::writeModelEquationsOrdered_M(const string &basename) const
       output << "  global options_;" << endl;
       //The Temporary terms
       if (simulation_type != EVALUATE_BACKWARD && simulation_type != EVALUATE_FORWARD)
-        output << " g1 = spalloc("  << block_mfs << ", " << block_mfs << ", " << derivative_endo[block].size() << ");" << endl;
+        output << " g1 = spalloc("  << block_mfs << ", " << block_mfs << ", " << blocks_derivatives[block].size() << ");" << endl;
 
       if (v_temporary_terms_inuse[block].size())
         {