diff --git a/matlab/perfect-foresight-models/solve_stacked_linear_problem.m b/matlab/perfect-foresight-models/solve_stacked_linear_problem.m
index b0f91b349780de44ac5f391fbc3cdef922f65a17..fba7478ddbdd0c3aef1329512595de17030f6707 100644
--- a/matlab/perfect-foresight-models/solve_stacked_linear_problem.m
+++ b/matlab/perfect-foresight-models/solve_stacked_linear_problem.m
@@ -20,26 +20,26 @@ function [endogenousvariables, info] = solve_stacked_linear_problem(endogenousva
 [options, y0, yT, z, i_cols, i_cols_J1, i_cols_T, i_cols_j, i_cols_1, dynamicmodel] = ...
     initialize_stacked_problem(endogenousvariables, options, M);
 
-ip = find(M_.lead_lag_incidence(1,:)');
-ic = find(M_.lead_lag_incidence(2,:)');
-in = find(M_.lead_lag_incidence(3,:)');
+ip = find(M.lead_lag_incidence(1,:)');
+ic = find(M.lead_lag_incidence(2,:)');
+in = find(M.lead_lag_incidence(3,:)');
 
 % Evaluate the Jacobian of the dynamic model at the deterministic steady state.
-[d1,jacobian] = dynamicmodel(y_steady_state([ip; ic; in]), transpose(steadystate_x), M.params, steadystate_y, 1);
+[d1,jacobian] = dynamicmodel(steadystate_y([ip; ic; in]), transpose(steadystate_x), M.params, steadystate_y, 1);
 
 % Check that the dynamic model was evaluated at the steady state.
 if max(abs(d1))>1e-12
     error('Jacobian is not evaluated at the steady state!')
 end
 
-nyp = nnz(M_.lead_lag_incidence(1,:));
-ny0 = nnz(M_.lead_lag_incidence(2,:));
-nyf = nnz(M_.lead_lag_incidence(3,:));
+nyp = nnz(M.lead_lag_incidence(1,:));
+ny0 = nnz(M.lead_lag_incidence(2,:));
+nyf = nnz(M.lead_lag_incidence(3,:));
 nd = nyp+ny0+nyf; % size of y (first argument passed to the dynamic file).
-jexog = transpose(nd+(1:M_.exo_nbr));
+jexog = transpose(nd+(1:M.exo_nbr));
 jendo = transpose(1:nd);
 z = bsxfun(@minus, z, steadystate_y);
-x = bsxfun(@minus, exogenousvariables, steadystate_x);
+x = bsxfun(@minus, exogenousvariables, steadystate_x');
 
 [y, check] = dynare_solve(@linear_perfect_foresight_problem,z(:), options, ...
                         jacobian, y0-steadystate_y, yT-steadystate_y, ...