diff --git a/src/DynamicModel.hh b/src/DynamicModel.hh
index c5db10002d3126857b56e80fea70fc4361c61b5e..d857a9eb92d2bb61ee036164ef83194238ccfeaf 100644
--- a/src/DynamicModel.hh
+++ b/src/DynamicModel.hh
@@ -959,44 +959,28 @@ DynamicModel::writeParamsDerivativesFile(const string &basename) const
                        << "end" << endl;
     }
   else
-    paramsDerivsFile << "module " << basename << "DynamicParamsDerivs" << endl
-                     << "#" << endl
-                     << "# NB: this file was automatically generated by Dynare" << endl
+    paramsDerivsFile << "# NB: this file was automatically generated by Dynare" << endl
                      << "#     from " << basename << ".mod" << endl
                      << "#" << endl
-                     << "export params_derivs" << endl << endl
-                     << "function params_derivs(y, x, paramssteady_state, it_, "
+                     << "function dynamic_params_derivs(y, x, paramssteady_state, it_,"
                      << "ss_param_deriv, ss_param_2nd_deriv)" << endl
 		     << "@inbounds begin" << endl
                      << tt_output.str()
-		     << "end" << endl
                      << "rp = zeros(" << equations.size() << ", "
                      << symbol_table.param_nbr() << ");" << endl
-		     << "@inbounds begin" << endl
                      << rp_output.str()
-		     << "end" << endl
                      << "gp = zeros(" << equations.size() << ", " << getJacobianColsNbr(false) << ", " << symbol_table.param_nbr() << ");" << endl
-		     << "@inbounds begin" << endl
                      << gp_output.str()
-		     << "end" << endl
                      << "rpp = zeros(" << params_derivatives.at({ 0, 2 }).size() << ",4);" << endl
-		     << "@inbounds begin" << endl
                      << rpp_output.str()
-		     << "end" << endl
                      << "gpp = zeros(" << params_derivatives.at({ 1, 2 }).size() << ",5);" << endl
-		     << "@inbounds begin" << endl
                      << gpp_output.str()
-		     << "end" << endl
                      << "hp = zeros(" << params_derivatives.at({ 2, 1 }).size() << ",5);" << endl
-		     << "@inbounds begin" << endl
                      << hp_output.str()
-		     << "end" << endl
                      << "g3p = zeros(" << params_derivatives.at({ 3, 1 }).size() << ",6);" << endl
-		     << "@inbounds begin" << endl
                      << g3p_output.str()
 		     << "end" << endl
-                     << "(rp, gp, rpp, gpp, hp, g3p)" << endl
-                     << "end" << endl
+                     << "return (rp, gp, rpp, gpp, hp, g3p)" << endl
                      << "end" << endl;
 
   paramsDerivsFile.close();
diff --git a/src/ModelEquationBlock.cc b/src/ModelEquationBlock.cc
index 745fb6da0f8bcd028c87d97bf469748bca06284b..ef78b7d95526d09ca838eefea553df650d137abf 100644
--- a/src/ModelEquationBlock.cc
+++ b/src/ModelEquationBlock.cc
@@ -221,12 +221,9 @@ SteadyStateModel::writeSteadyStateFile(const string &basename, bool julia) const
            << "% Steady state generated by Dynare preprocessor" << endl
            << "    info = 0;" << endl;
   else
-    output << "module " << basename << "SteadyState2" << endl
-           << "#" << endl
-           << "# NB: this file was automatically generated by Dynare" << endl
+    output << "# NB: this file was automatically generated by Dynare" << endl
            << "#     from " << basename << ".mod" << endl
            << "#" << endl
-           << "export steady_state!" << endl << endl
            << "function steady_state!(ys_::Vector{<: Real}, exo_::Vector{<: Real}, "
            << "params::Vector{<: Real})" << endl
 	   << "@inbounds begin" << endl;
@@ -257,7 +254,7 @@ SteadyStateModel::writeSteadyStateFile(const string &basename, bool julia) const
 
   output << "end" << endl;
   if (julia)
-    output << "end" << endl << "end" << endl;
+    output << "end" << endl;
 
   if (julia)
     writeToFileIfModified(output, filesystem::path{basename} / "model" / "julia" / "SteadyState2.jl");
diff --git a/src/StaticModel.hh b/src/StaticModel.hh
index 6ec94ac498b60fdac4a541785c637e2e0eb7da79..002ffff2557cefd2e53244c0ae873eef1e07e715 100644
--- a/src/StaticModel.hh
+++ b/src/StaticModel.hh
@@ -294,40 +294,26 @@ StaticModel::writeParamsDerivativesFile(const string &basename) const
                        << "end" << endl;
     }
   else
-    paramsDerivsFile << "module " << basename << "StaticParamsDerivs" << endl
-                     << "#" << endl
-                     << "# NB: this file was automatically generated by Dynare" << endl
+    paramsDerivsFile << "# NB: this file was automatically generated by Dynare" << endl
                      << "#     from " << basename << ".mod" << endl
                      << "#" << endl
-                     << "export params_derivs" << endl << endl
-                     << "function params_derivs(y, x, params)" << endl
+                     << "function static_params_derivs(y, x, params)" << endl
 		     << "@inbounds begin" << endl
                      << tt_output.str()
-		     << "end" << endl
                      << "rp = zeros(" << equations.size() << ", "
                      << symbol_table.param_nbr() << ");" << endl
-		     << "@inbounds begin" << endl
                      << rp_output.str()
-		     << "end" << endl
                      << "gp = zeros(" << equations.size() << ", " << symbol_table.endo_nbr() << ", "
                      << symbol_table.param_nbr() << ");" << endl
-		     << "@inbounds begin" << endl
                      << gp_output.str()
-		     << "end" << endl
                      << "rpp = zeros(" << params_derivatives.at({ 0, 2 }).size() << ",4);" << endl
-		     << "@inbounds begin" << endl
                      << rpp_output.str()
-		     << "end" << endl
                      << "gpp = zeros(" << params_derivatives.at({ 1, 2 }).size() << ",5);" << endl
-		     << "@inbounds begin" << endl
                      << gpp_output.str()
-		     << "end" << endl
                      << "hp = zeros(" << params_derivatives.at({ 2, 1 }).size() << ",5);" << endl
-		     << "@inbounds begin" << endl
                      << hp_output.str()
 		     << "end" << endl
-                     << "(rp, gp, rpp, gpp, hp)" << endl
-                     << "end" << endl
+                     << "return (rp, gp, rpp, gpp, hp)" << endl
                      << "end" << endl;
 
   paramsDerivsFile.close();