diff --git a/matlab/ep/ep_problem_2.m b/matlab/ep/ep_problem_2.m
index d94f277f8b374810675d9c8bfda99fafb43ac342..2fda1838bc7d4532764ea9a53bd0d0721de732de 100644
--- a/matlab/ep/ep_problem_2.m
+++ b/matlab/ep/ep_problem_2.m
@@ -39,7 +39,7 @@ i_hc = i_cols_f - 2*ny;
 
 nzA = cell(periods,world_nbr);
 res = zeros(ny,periods,world_nbr);
-Y = pfm.Y; %zeros(ny*(periods+2),world_nbr);
+Y = zeros(ny*(periods+2),world_nbr);
 Y(1:ny,1) = pfm.y0;
 Y(end-ny+1:end,:) = repmat(steady_state,1,world_nbr);
 Y(pfm.i_upd_y) = y;
diff --git a/matlab/ep/solve_stochastic_perfect_foresight_model_0.m b/matlab/ep/solve_stochastic_perfect_foresight_model_0.m
index 02947bb21b63db46055a9b2f739529c9ef50f990..19e77a8315a6b2afdb96b742f01c66be4c9ed515 100644
--- a/matlab/ep/solve_stochastic_perfect_foresight_model_0.m
+++ b/matlab/ep/solve_stochastic_perfect_foresight_model_0.m
@@ -78,7 +78,6 @@ if update_pfm_struct
     [~, jacobian] = dynamic_model(z, exo_simul, pfm.params, pfm.steady_state, 2);
 
     world_nbr = nnodes^order;
-    Y = repmat(endo_simul(:),1,world_nbr);
 
     % The columns of A map the elements of Y such that
     % each block of Y with ny rows are unfolded column wise
@@ -142,12 +141,13 @@ if update_pfm_struct
     pfm.i_cols_T = i_cols_T;
     pfm.i_upd_r = i_upd_r;
     pfm.i_upd_y = i_upd_y;
-    pfm.Y = Y;
 
     pfm.dimension = dimension;
 
 end
 
+pfm.Y = repmat(endo_simul(:),1,pfm.world_nbr);
+
 y = repmat(pfm.steady_state, pfm.dimension/pfm.ny, 1);
 
 if update_options_struct
diff --git a/matlab/ep/solve_stochastic_perfect_foresight_model_1.m b/matlab/ep/solve_stochastic_perfect_foresight_model_1.m
index d65c464757f618f76f8c8e097334869d8620068e..ccdc882f61ae42003c44eb19e3761bf80d05bebf 100644
--- a/matlab/ep/solve_stochastic_perfect_foresight_model_1.m
+++ b/matlab/ep/solve_stochastic_perfect_foresight_model_1.m
@@ -72,9 +72,6 @@ if update_pfm_struct
     % The third row block is ny x nnodes^2
     % and so on until size ny x nnodes^order
     world_nbr = pfm.world_nbr;
-    % Y = endo_simul(:,2:end-1);
-    pfm.Y = repmat(endo_simul(:), 1, world_nbr);
-    pfm.y0 = endo_simul(:,1);
 
     % The columns of A map the elements of Y such that
     % each block of Y with ny rows are unfolded column wise
@@ -133,5 +130,7 @@ if update_options_struct
     end
 end
 
+pfm.y0 = endo_simul(:,1);
+
 [y, errorflag, ~, ~, errorcode] = dynare_solve(@ep_problem_2, y, options_.simul.maxit, options_.dynatol.f, options_.dynatol.x, options_, exo_simul, pfm);
 endo_simul(:,2) = y(1:pfm.ny);