diff --git a/matlab/dr1.m b/matlab/dr1.m
index a834900785952ead057948657badbd70195b70a1..2169a7a46a01c586675b56377a3e0f87d5814eb5 100644
--- a/matlab/dr1.m
+++ b/matlab/dr1.m
@@ -530,6 +530,9 @@ function [dr,info,M_,options_,oo_] = dr1(dr,task,M_,options_,oo_)
     zu=[zu; eye(M_.exo_nbr);zeros(M_.exo_det_nbr,M_.exo_nbr)];
     [nrzx,nczx] = size(zx);
     
+    % Workaround for USE_DLL option: at this time, it returns a full hessian
+    hessian = sparse(hessian);
+    
     rhs = -sparse_hessian_times_B_kronecker_C(hessian,zx);
     
     %lhs
diff --git a/preprocessor/ModelTree.cc b/preprocessor/ModelTree.cc
index 78b2d33edcf97c7625d4a23ee61a61da9fc203f9..21df8f0f2e9206e81aea6bbf207aed52f4c7bd6f 100644
--- a/preprocessor/ModelTree.cc
+++ b/preprocessor/ModelTree.cc
@@ -1754,10 +1754,8 @@ ModelTree::writeDynamicCFile(const string &dynamic_basename) const
                     << "  g2 = NULL;" << endl
                     << " if (nlhs >= 3)" << endl
                     << "  {" << endl
-                    << "     /* Set the output pointer to the output matrix g2. */" << endl;
-  int g2_ncols = variable_table.getDynJacobianColsNbr(computeJacobianExo)*variable_table.getDynJacobianColsNbr(computeJacobianExo);
-  mDynamicModelFile << "     plhs[2] = mxCreateSparse(" << equations.size() << ", " << g2_ncols << ", "
-                    << 5*g2_ncols << ", mxREAL);" << endl
+                    << "     /* Set the output pointer to the output matrix g2. */" << endl
+                    << "     plhs[2] = mxCreateDoubleMatrix(" << equations.size() << ", " << variable_table.getDynJacobianColsNbr(computeJacobianExo)*variable_table.getDynJacobianColsNbr(computeJacobianExo) << ", mxREAL);" << endl
                     << "     /* Create a C pointer to a copy of the output matrix g1. */" << endl
                     << "     g2 = mxGetPr(plhs[2]);" << endl
                     << "  }" << endl