diff --git a/doc/manual/source/running-dynare.rst b/doc/manual/source/running-dynare.rst
index 60469e61d6a56ea18d06b0127124708f0ff6ddc9..824d9f826816f553bfaa33d5577f0f8e881a06e1 100644
--- a/doc/manual/source/running-dynare.rst
+++ b/doc/manual/source/running-dynare.rst
@@ -548,7 +548,8 @@ by the ``dynare`` command.
     results in the workspace available for further processing. More
     details are given under the relevant computing tasks. The
     ``M_``,``oo_``, and ``options_`` structures are saved in a file
-    called ``FILENAME_results.mat``. If they exist, ``estim_params_``,
+    called ``FILENAME_results.mat`` located in the ``MODFILENAME/Output`` folder.
+    If they exist, ``estim_params_``,
     ``bayestopt_``, ``dataset_``, ``oo_recursive_`` and
     ``estimation_info`` are saved in the same file. Note that Matlab 
     by default only allows ``.mat``-files up to 2GB. You can lift this 
diff --git a/doc/manual/source/the-model-file.rst b/doc/manual/source/the-model-file.rst
index fa0e2c0661c1cefa6b3bac4b767c1cb9827963ca..fcc42707b2cd5986c8ba9b147611722c5b9d3b4a 100644
--- a/doc/manual/source/the-model-file.rst
+++ b/doc/manual/source/the-model-file.rst
@@ -3890,7 +3890,8 @@ Computing the stochastic solution
        requested (i.e. ``periods`` :math:`>` 0). Note that if this
        option is greater than 1, the additional series will not be
        used for computing the empirical moments but will simply be
-       saved in binary form to the file ``FILENAME_simul``. Default:
+       saved in binary form to the file ``FILENAME_simul`` in the 
+       ``FILENAME/Output``-folder. Default:
        ``1``.
 
     .. option:: solve_algo = INTEGER
@@ -5297,7 +5298,8 @@ block decomposition of the model (see :opt:`block`).
        achieve an acceptance rate of
        :ref:`AcceptanceRateTarget<art>`. The resulting scale parameter
        will be saved into a file named
-       ``MODEL_FILENAME_mh_scale.mat.`` This file can be loaded in
+       ``MODEL_FILENAME_mh_scale.mat`` in the ``FILENAME/Output``-folder.
+       This file can be loaded in
        subsequent runs via the ``posterior_sampler_options`` option
        :ref:`scale_file <scale-file>`. Both ``mode_compute=6`` and
        ``scale_file`` will overwrite any value specified in
@@ -5378,7 +5380,8 @@ block decomposition of the model (see :opt:`block`).
        Name of the file containing previous value for the mode. When
        computing the mode, Dynare stores the mode (``xparam1``) and
        the hessian (``hh``, only if ``cova_compute=1``) in a file
-       called ``MODEL_FILENAME_mode.mat``. After a successful run of
+       called ``MODEL_FILENAME_mode.mat`` in the ``FILENAME/Output``-folder. 
+       After a successful run of
        the estimation command, the ``mode_file`` will be disabled to
        prevent other function calls from implicitly using an updated
        ``mode-file``. Thus, if the mod-file contains subsequent
diff --git a/matlab/compute_mh_covariance_matrix.m b/matlab/compute_mh_covariance_matrix.m
index ffd0b218e350ad200cf769f24856bbbb4572186d..662d7b25a9e6e9747e863037e94a91cbd87ff5e4 100644
--- a/matlab/compute_mh_covariance_matrix.m
+++ b/matlab/compute_mh_covariance_matrix.m
@@ -78,4 +78,4 @@ hh = inv(posterior_covariance);
 fval = posterior_kernel_at_the_mode;
 parameter_names = bayestopt_.name;
 
-save([M_.fname '_mh_mode.mat'],'xparam1','hh','fval','parameter_names');
\ No newline at end of file
+save([M_.dname filesep 'Output' filesep M_.fname '_mh_mode.mat'],'xparam1','hh','fval','parameter_names');
\ No newline at end of file
diff --git a/matlab/dynare_estimation.m b/matlab/dynare_estimation.m
index 073929ee173a2adaff68b0bcb62a8f42d3aaa31a..a790d8a87c3a4ec0b13704982802313a1416994d 100644
--- a/matlab/dynare_estimation.m
+++ b/matlab/dynare_estimation.m
@@ -101,7 +101,7 @@ if nnobs>1 || nfirstobs > 1
         end
         dynare_estimation_1(var_list,M_.dname);
         if isequal(i,1) && options_.mode_compute ~= 0
-            options_.mode_file = [M_.fname '_mode'];
+            options_.mode_file = [M_.dname filesep 'Output' filesep M_.fname '_mode'];
         end
         if options_.recursive_estimation_restart
             for j=1:options_.recursive_estimation_restart
diff --git a/matlab/dynare_estimation_1.m b/matlab/dynare_estimation_1.m
index ee51830f9fc2a32027a7ace39b2d8ecd12edd825..311f283bee5a6afc0d75de784f6fb390fe64fbf9 100644
--- a/matlab/dynare_estimation_1.m
+++ b/matlab/dynare_estimation_1.m
@@ -31,6 +31,10 @@ function dynare_estimation_1(var_list_,dname)
 
 global M_ options_ oo_ estim_params_ bayestopt_ dataset_ dataset_info
 
+if ~exist([M_.dname filesep 'Output'],'dir')
+    mkdir(M_.dname,'Output');
+end
+
 if isempty(estim_params_)
     mode_compute_o = options_.mode_compute;
     mh_replic_o = options_.mh_replic;
@@ -206,7 +210,7 @@ if ~isequal(options_.mode_compute,0) && ~options_.mh_posterior_mode_estimation
         newratflag = new_rat_hess_info.newratflag;
         new_rat_hess_info = new_rat_hess_info.new_rat_hess_info;
     elseif isnumeric(options_.mode_compute) && options_.mode_compute==6 %save scaling factor
-        save([M_.fname '_optimal_mh_scale_parameter.mat'],'Scale');
+        save([M_.dname filesep 'Output' filesep M_.fname '_optimal_mh_scale_parameter.mat'],'Scale');
         options_.mh_jscale = Scale;
         bayestopt_.jscale(:) = options_.mh_jscale;
     end
@@ -260,9 +264,9 @@ if ~isequal(options_.mode_compute,0) && ~options_.mh_posterior_mode_estimation
     end
     parameter_names = bayestopt_.name;
     if options_.cova_compute || options_.mode_compute==5 || options_.mode_compute==6
-        save([M_.fname '_mode.mat'],'xparam1','hh','parameter_names','fval');
+        save([M_.dname filesep 'Output' filesep M_.fname '_mode.mat'],'xparam1','hh','parameter_names','fval');
     else
-        save([M_.fname '_mode.mat'],'xparam1','parameter_names','fval');
+        save([M_.dname filesep 'Output' filesep M_.fname '_mode.mat'],'xparam1','parameter_names','fval');
     end
 end
 
@@ -375,7 +379,7 @@ end
 
 if np > 0
     pindx = estim_params_.param_vals(:,1);
-    save([M_.fname '_params.mat'],'pindx');
+    save([M_.dname filesep 'Output' filesep M_.fname '_params.mat'],'pindx');
 end
 
 switch options_.MCMC_jumping_covariance
@@ -472,7 +476,7 @@ if (any(bayestopt_.pshape  >0 ) && options_.mh_replic) || ...
     else
         %get stored results if required
         if options_.load_mh_file && options_.load_results_after_load_mh
-            oo_load_mh=load([M_.fname '_results'],'oo_');
+            oo_load_mh=load([M_.dname filesep 'Output' filesep M_.fname '_results'],'oo_');
         end
         if ~options_.nodiagnostic
             if (options_.mh_replic>0 || (options_.load_mh_file && ~options_.load_results_after_load_mh))
@@ -778,7 +782,7 @@ end
 
 if np > 0
     pindx = estim_params_.param_vals(:,1);
-    save([M_.fname '_pindx.mat'] ,'pindx');
+    save([M_.dname filesep 'Output' filesep M_.fname '_pindx.mat'] ,'pindx');
 end
 
 %reset qz_criterium
diff --git a/matlab/gsa/filt_mc_.m b/matlab/gsa/filt_mc_.m
index d15c6789d1acc495df50b6613fc70c2f4a2060f6..74b7c0fe106c7dd6ebf9058916e8cea892cf1976 100644
--- a/matlab/gsa/filt_mc_.m
+++ b/matlab/gsa/filt_mc_.m
@@ -92,11 +92,11 @@ if ~isempty(options_.mode_file)
     load(options_.mode_file,'xparam1')
 end
 if options_.opt_gsa.ppost
-    c=load([fname_,'_mean.mat'],'xparam1');
+    c=load([M_.dname filesep 'Output' filesep fname_,'_mean.mat'],'xparam1');
     xparam1_mean=c.xparam1;
     clear c
-elseif ~isempty(options_.mode_file) && exist([fname_,'_mean.mat'])==2
-    c=load([fname_,'_mean.mat'],'xparam1');
+elseif ~isempty(options_.mode_file) && exist([M_.dname filesep 'Output' filesep fname_,'_mean.mat'])==2
+    c=load([M_.dname filesep 'Output' filesep fname_,'_mean.mat'],'xparam1');
     xparam1_mean=c.xparam1;
     clear c
 end
diff --git a/matlab/marginal_density.m b/matlab/marginal_density.m
index 995df30a8e6489f69ca28bfcf35582b327210041..bd10e86ea0a4df50dd339c097613c3fcf34a811c 100644
--- a/matlab/marginal_density.m
+++ b/matlab/marginal_density.m
@@ -66,7 +66,7 @@ end
 % (usefull if the user wants to perform some computations using
 % the posterior mean instead of the posterior mode ==> ).
 parameter_names = bayestopt_.name;
-save([M_.fname '_mean.mat'],'xparam1','hh','parameter_names','SIGMA');
+save([M_.dname filesep 'Output' filesep M_.fname '_mean.mat'],'xparam1','hh','parameter_names','SIGMA');
 
 fprintf('Estimation::marginal density: I''m computing the posterior log marginal density (modified harmonic mean)... ');
 logdetSIGMA = log(det(SIGMA));
diff --git a/matlab/model_comparison.m b/matlab/model_comparison.m
index f49320adf2eea7abab464903f3564b1bd359870d..302bda814c660c375597962e601db05abfb4f02e 100644
--- a/matlab/model_comparison.m
+++ b/matlab/model_comparison.m
@@ -81,9 +81,9 @@ for i=1:NumberOfModels
         mstruct.oo_ = oo;
     else
         if strcmpi(ModelNames{i}(end-3:end),'.mod') || strcmpi(ModelNames{i}(end-3:end),'.dyn')
-            mstruct = load([ModelNames{i}(1:end-4) '_results.mat' ],'oo_');
+            mstruct = load([ModelNames{i}(1:end-4) filesep 'Output' ModelNames{i}(1:end-4) '_results.mat' ],'oo_');
         else
-            mstruct = load([ModelNames{i} '_results.mat' ],'oo_');
+            mstruct = load([ModelNames{i} filesep 'Output' filesep ModelNames{i} '_results.mat' ],'oo_');
         end
     end
     try
diff --git a/matlab/partial_information/dr1_PI.m b/matlab/partial_information/dr1_PI.m
index a8cbc93d986ba8ad6d1a365a776c383eb7ddbc90..dfafa44a07471de45183d57d76dfeaf7ca57b468 100644
--- a/matlab/partial_information/dr1_PI.m
+++ b/matlab/partial_information/dr1_PI.m
@@ -154,7 +154,7 @@ else
 end
 
 if options_.debug
-    save([M_.fname '_debug.mat'],'jacobia_')
+    save([M_.dname filesep 'Output' filesep M_.fname '_debug.mat'],'jacobia_')
 end
 
 dr=set_state_space(dr,M_,options_);
diff --git a/matlab/simult.m b/matlab/simult.m
index c03fb78db4eb507c34b38b6fc6fc66c30825b2ab..caeae45c4f389e8aaf703f452e6bbfd45a681c79 100644
--- a/matlab/simult.m
+++ b/matlab/simult.m
@@ -66,7 +66,7 @@ order = DynareOptions.order;
 replic = DynareOptions.simul_replic;
 
 if replic > 1
-    fname = [DynareModel.fname,'_simul'];
+    fname = [DynareModel.dname filesep 'Output' DynareModel.fname,'_simul'];
     fh = fopen(fname,'w+');
 end
 
diff --git a/matlab/stochastic_solvers.m b/matlab/stochastic_solvers.m
index 3b8d770fc239123ce81a458e4f1bddb5600d7ed1..4e044856856e2f112346dad9ceb15483e95d1c29 100644
--- a/matlab/stochastic_solvers.m
+++ b/matlab/stochastic_solvers.m
@@ -128,7 +128,7 @@ elseif local_order == 2
         if ~isempty(infrow)
             fprintf('\nSTOCHASTIC_SOLVER: The Hessian of the dynamic model contains Inf.\n')
             fprintf('STOCHASTIC_SOLVER: Try running model_diagnostics to find the source of the problem.\n')
-            save([M_.fname '_debug.mat'],'hessian1')
+            save([M_.dname filesep 'Output' filesep M_.fname '_debug.mat'],'hessian1')
         end
     end
     if ~isempty(infrow)
@@ -140,7 +140,7 @@ elseif local_order == 2
         if ~isempty(nanrow)
             fprintf('\nSTOCHASTIC_SOLVER: The Hessian of the dynamic model contains NaN.\n')
             fprintf('STOCHASTIC_SOLVER: Try running model_diagnostics to find the source of the problem.\n')
-            save([M_.fname '_debug.mat'],'hessian1')
+            save([M_.dname filesep 'Output' filesep M_.fname '_debug.mat'],'hessian1')
         end
     end
     if ~isempty(nanrow)
@@ -155,7 +155,7 @@ if options_.debug
     if ~isempty(infrow)
         fprintf('\nSTOCHASTIC_SOLVER: The Jacobian of the dynamic model contains Inf. The problem is associated with:\n\n')
         display_problematic_vars_Jacobian(infrow,infcol,M_,dr.ys,'dynamic','STOCHASTIC_SOLVER: ')
-        save([M_.fname '_debug.mat'],'jacobia_')
+        save([M_.dname filesep 'Output' filesep M_.fname '_debug.mat'],'jacobia_')
     end
 end
 
@@ -184,7 +184,7 @@ if options_.debug
     if ~isempty(nanrow)
         fprintf('\nSTOCHASTIC_SOLVER: The Jacobian of the dynamic model contains NaN. The problem is associated with:\n\n')
         display_problematic_vars_Jacobian(nanrow,nancol,M_,dr.ys,'dynamic','STOCHASTIC_SOLVER: ')
-        save([M_.fname '_debug.mat'],'jacobia_')
+        save([M_.dname filesep 'Output' filesep M_.fname '_debug.mat'],'jacobia_')
     end
 end
 
diff --git a/preprocessor b/preprocessor
index 5cfe6303e26fcaeff204e6d2ca3988b169621f46..bb19d98712f2599380dfc704f98b33531d7414de 160000
--- a/preprocessor
+++ b/preprocessor
@@ -1 +1 @@
-Subproject commit 5cfe6303e26fcaeff204e6d2ca3988b169621f46
+Subproject commit bb19d98712f2599380dfc704f98b33531d7414de
diff --git a/tests/AIM/fs2000_b1L1L_AIM.mod b/tests/AIM/fs2000_b1L1L_AIM.mod
index 71a0ec1ade9d0a7e004b9d602cb9e5474e1b9d5e..ffd5d5bb079d1e3b58cba41dc2afc3ffb7360348 100644
--- a/tests/AIM/fs2000_b1L1L_AIM.mod
+++ b/tests/AIM/fs2000_b1L1L_AIM.mod
@@ -92,7 +92,7 @@ steady(nocheck);
  
 stoch_simul(aim_solver, order=1, irf=0);
  
-benchmark = load('fs2000_b1L1L_results');
+benchmark = load(['fs2000_b1L1L' filesep 'Output' filesep 'fs2000_b1L1L_results']);
 threshold = 1e-8;
  
 if max(max(abs(benchmark.oo_.dr.ghx-oo_.dr.ghx) > threshold));
diff --git a/tests/AIM/fs2000x10L9_L_AIM.mod b/tests/AIM/fs2000x10L9_L_AIM.mod
index e651ff93d8315ce349ecae96c0ed0c40141bd68f..e52b2db37dd8423a63116ffbef039fb1ef37def1 100644
--- a/tests/AIM/fs2000x10L9_L_AIM.mod
+++ b/tests/AIM/fs2000x10L9_L_AIM.mod
@@ -76,7 +76,7 @@ check;
 
 stoch_simul(aim_solver, order=1,irf=0);
  
-benchmark = load('fs2000x10L9_L_results');
+benchmark = load(['fs2000x10L9_L' filesep 'Output' filesep 'fs2000x10L9_L_results']);
 threshold = 1e-8;
  
 if max(max(abs(benchmark.oo_.dr.ghx-oo_.dr.ghx) > threshold));
diff --git a/tests/AIM/fs2000x10_L9_L_AIM.mod b/tests/AIM/fs2000x10_L9_L_AIM.mod
index fa80630c06196cd2b8ebcfc65c40d981faadacf5..92c5c2179b03c602ec5d66b56217d7ede7dd238f 100644
--- a/tests/AIM/fs2000x10_L9_L_AIM.mod
+++ b/tests/AIM/fs2000x10_L9_L_AIM.mod
@@ -57,7 +57,7 @@ steady;
 
 stoch_simul(aim_solver, order=1,irf=0);
 
-benchmark = load('fs2000x10_L9_L_results');
+benchmark = load(['fs2000x10_L9_L' filesep 'Output' filesep 'fs2000x10_L9_L_results']);
 threshold = 1e-8;
  
 if max(max(abs(benchmark.oo_.dr.ghx-oo_.dr.ghx) > threshold));
diff --git a/tests/AIM/ls2003_2L0L_AIM.mod b/tests/AIM/ls2003_2L0L_AIM.mod
index 8ff90c3e5a49c72634cff90f61a0e45cbf9cfe90..175b85242638eac1e24cc80cacba3dd41488b10b 100644
--- a/tests/AIM/ls2003_2L0L_AIM.mod
+++ b/tests/AIM/ls2003_2L0L_AIM.mod
@@ -45,7 +45,7 @@ end;
 
 stoch_simul(aim_solver, order=1,irf=0);
  
-benchmark = load('ls2003_2L0L_results');
+benchmark = load(['ls2003_2L0L' filesep 'Output' filesep 'ls2003_2L0L_results']);
 threshold = 1e-8;
  
 if max(max(abs(benchmark.oo_.dr.ghx-oo_.dr.ghx) > threshold));
diff --git a/tests/AIM/ls2003_2L2L_AIM.mod b/tests/AIM/ls2003_2L2L_AIM.mod
index 11f60720dc99d856e28e7f4c12e7e7ad2ec1fe59..0fcef43fffc2ce4422c2d8f469e14e199804a2a3 100644
--- a/tests/AIM/ls2003_2L2L_AIM.mod
+++ b/tests/AIM/ls2003_2L2L_AIM.mod
@@ -43,7 +43,7 @@ end;
 
 stoch_simul(aim_solver, order=1,irf=0);
  
-benchmark = load('ls2003_2L2L_results');
+benchmark = load(['ls2003_2L2L' filesep 'Output' filesep 'ls2003_2L2L_results']);
 threshold = 1e-8;
  
 if max(max(abs(benchmark.oo_.dr.ghx-oo_.dr.ghx) > threshold));
diff --git a/tests/Makefile.am b/tests/Makefile.am
index aa84d1cf018f4609e8c0d004ada0c66d9b524302..5f981419e2312c4cffb3dc1388a4717524edd798 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -1412,13 +1412,6 @@ clean-local:
 	rm -f $(patsubst %.trs, %.json, $(O_TRS_FILES))
 	rm -f $(patsubst %.trs, %.json, $(O_XFAIL_TRS_FILES))
 
-	rm -f $(patsubst %.mod, %_results.mat, $(MODFILES))
-	rm -f $(patsubst %.mod, %_mode.mat, $(MODFILES))
-	rm -f $(patsubst %.mod, %_mh_mode.mat, $(MODFILES))
-	rm -f $(patsubst %.mod, %_mean.mat, $(MODFILES))
-	rm -f $(patsubst %.mod, %_pindx.mat, $(MODFILES))
-	rm -f $(patsubst %.mod, %_params.mat, $(MODFILES))
-	rm -f $(patsubst %.mod, %_simul, $(MODFILES))
 	rm -f $(patsubst %.mod, %.log, $(MODFILES))
 
 	rm -rf $(patsubst %.mod, %, $(MODFILES))
diff --git a/tests/analytic_derivatives/fs2000_analytic_derivation.mod b/tests/analytic_derivatives/fs2000_analytic_derivation.mod
index 677b0f2e12d4d40b96608e0472e4b6940260fbcb..c74af9d655ba857bbf4d7e44106fd924cfa2799a 100644
--- a/tests/analytic_derivatives/fs2000_analytic_derivation.mod
+++ b/tests/analytic_derivatives/fs2000_analytic_derivation.mod
@@ -78,22 +78,22 @@ options_.solve_tolf = 1e-12;
 
 estimation(order=1,mode_compute=9,analytic_derivation,kalman_algo=1,datafile=my_data,nobs=192,mh_replic=0,mh_nblocks=2,mh_jscale=0.8,plot_priors=0,prior_trunc=0);
 if (isoctave && user_has_octave_forge_package('optim', '1.6')) || (~isoctave && user_has_matlab_license('optimization_toolbox'))
-    estimation(order=1,mode_compute=1,mode_file=fs2000_analytic_derivation_mode,analytic_derivation,kalman_algo=1,datafile=my_data,nobs=192,mh_replic=0,mh_nblocks=2,mh_jscale=0.8,plot_priors=0
+    estimation(order=1,mode_compute=1,mode_file='fs2000_analytic_derivation/Output/fs2000_analytic_derivation_mode',analytic_derivation,kalman_algo=1,datafile=my_data,nobs=192,mh_replic=0,mh_nblocks=2,mh_jscale=0.8,plot_priors=0
     %,optim = ('DerivativeCheck', 'on','FiniteDifferenceType','central')
     );
-    estimation(order=1,mode_compute=3,mode_file=fs2000_analytic_derivation_mode,analytic_derivation,kalman_algo=1,datafile=my_data,nobs=192,mh_replic=0,mh_nblocks=2,mh_jscale=0.8,plot_priors=0);
-    estimation(order=1,mode_compute=101,mode_file=fs2000_analytic_derivation_mode,analytic_derivation,kalman_algo=1,datafile=my_data,nobs=192,mh_replic=0,mh_nblocks=2,mh_jscale=0.8,plot_priors=0);    
+    estimation(order=1,mode_compute=3,mode_file='fs2000_analytic_derivation/Output/fs2000_analytic_derivation_mode',analytic_derivation,kalman_algo=1,datafile=my_data,nobs=192,mh_replic=0,mh_nblocks=2,mh_jscale=0.8,plot_priors=0);
+    estimation(order=1,mode_compute=101,mode_file='fs2000_analytic_derivation/Output/fs2000_analytic_derivation_mode',analytic_derivation,kalman_algo=1,datafile=my_data,nobs=192,mh_replic=0,mh_nblocks=2,mh_jscale=0.8,plot_priors=0);    
 end
-estimation(order=1,mode_compute=5,mode_file=fs2000_analytic_derivation_mode,analytic_derivation,kalman_algo=2,datafile=my_data,nobs=192,mh_replic=0,mh_nblocks=2,mh_jscale=0.8,plot_priors=0);
-estimation(order=1,mode_compute=4,mode_file=fs2000_analytic_derivation_mode,analytic_derivation,kalman_algo=1,datafile=my_data,nobs=192,mh_replic=0,mh_nblocks=2,mh_jscale=0.8,plot_priors=0);
-estimation(order=1,mode_compute=4,mode_file=fs2000_analytic_derivation_mode,analytic_derivation,kalman_algo=2,datafile=my_data,nobs=192,mh_replic=0,mh_nblocks=2,mh_jscale=0.8,plot_priors=0);
+estimation(order=1,mode_compute=5,mode_file='fs2000_analytic_derivation/Output/fs2000_analytic_derivation_mode',analytic_derivation,kalman_algo=2,datafile=my_data,nobs=192,mh_replic=0,mh_nblocks=2,mh_jscale=0.8,plot_priors=0);
+estimation(order=1,mode_compute=4,mode_file='fs2000_analytic_derivation/Output/fs2000_analytic_derivation_mode',analytic_derivation,kalman_algo=1,datafile=my_data,nobs=192,mh_replic=0,mh_nblocks=2,mh_jscale=0.8,plot_priors=0);
+estimation(order=1,mode_compute=4,mode_file='fs2000_analytic_derivation/Output/fs2000_analytic_derivation_mode',analytic_derivation,kalman_algo=2,datafile=my_data,nobs=192,mh_replic=0,mh_nblocks=2,mh_jscale=0.8,plot_priors=0);
 options_.debug=1;
-estimation(order=1,mode_compute=0,mode_file=fs2000_analytic_derivation_mode,analytic_derivation,kalman_algo=1,datafile=my_data,nobs=192,mh_replic=0,plot_priors=0);
+estimation(order=1,mode_compute=0,mode_file='fs2000_analytic_derivation/Output/fs2000_analytic_derivation_mode',analytic_derivation,kalman_algo=1,datafile=my_data,nobs=192,mh_replic=0,plot_priors=0);
 fval_ML_1=oo_.likelihood_at_initial_parameters;
-estimation(order=1,mode_compute=0,mode_file=fs2000_analytic_derivation_mode,analytic_derivation,kalman_algo=2,datafile=my_data,nobs=192,mh_replic=0,plot_priors=0);
+estimation(order=1,mode_compute=0,mode_file='fs2000_analytic_derivation/Output/fs2000_analytic_derivation_mode',analytic_derivation,kalman_algo=2,datafile=my_data,nobs=192,mh_replic=0,plot_priors=0);
 fval_ML_2=oo_.likelihood_at_initial_parameters;
 options_.analytic_derivation=0;
-estimation(order=1,mode_compute=0,mode_file=fs2000_analytic_derivation_mode,kalman_algo=1,datafile=my_data,nobs=192,mh_replic=0,plot_priors=0);
+estimation(order=1,mode_compute=0,mode_file='fs2000_analytic_derivation/Output/fs2000_analytic_derivation_mode',kalman_algo=1,datafile=my_data,nobs=192,mh_replic=0,plot_priors=0);
 fval_ML_3=oo_.likelihood_at_initial_parameters;
 
 if abs(fval_ML_1-fval_ML_2)>1e-5 || abs(fval_ML_1-fval_ML_3)>1e-5
@@ -111,22 +111,22 @@ end;
 
 estimation(order=1,mode_compute=9,analytic_derivation,kalman_algo=1,datafile=my_data,nobs=192,mh_replic=0,mh_nblocks=2,mh_jscale=0.8,plot_priors=0,prior_trunc=0);
 if (isoctave && user_has_octave_forge_package('optim', '1.6')) || (~isoctave && user_has_matlab_license('optimization_toolbox'))
-    estimation(order=1,mode_compute=1,mode_file=fs2000_analytic_derivation_mode,analytic_derivation,kalman_algo=1,datafile=my_data,nobs=192,mh_replic=0,mh_nblocks=2,mh_jscale=0.8,plot_priors=0
+    estimation(order=1,mode_compute=1,mode_file='fs2000_analytic_derivation/Output/fs2000_analytic_derivation_mode',analytic_derivation,kalman_algo=1,datafile=my_data,nobs=192,mh_replic=0,mh_nblocks=2,mh_jscale=0.8,plot_priors=0
     %,optim = ('DerivativeCheck', 'on','FiniteDifferenceType','central')
     );
-    estimation(order=1,mode_compute=3,mode_file=fs2000_analytic_derivation_mode,analytic_derivation,kalman_algo=1,datafile=my_data,nobs=192,mh_replic=0,mh_nblocks=2,mh_jscale=0.8,plot_priors=0);
-    estimation(order=1,mode_compute=101,mode_file=fs2000_analytic_derivation_mode,analytic_derivation,kalman_algo=1,datafile=my_data,nobs=192,mh_replic=0,mh_nblocks=2,mh_jscale=0.8,plot_priors=0);    
+    estimation(order=1,mode_compute=3,mode_file='fs2000_analytic_derivation/Output/fs2000_analytic_derivation_mode',analytic_derivation,kalman_algo=1,datafile=my_data,nobs=192,mh_replic=0,mh_nblocks=2,mh_jscale=0.8,plot_priors=0);
+    estimation(order=1,mode_compute=101,mode_file='fs2000_analytic_derivation/Output/fs2000_analytic_derivation_mode',analytic_derivation,kalman_algo=1,datafile=my_data,nobs=192,mh_replic=0,mh_nblocks=2,mh_jscale=0.8,plot_priors=0);    
 end
-estimation(order=1,mode_compute=5,mode_file=fs2000_analytic_derivation_mode,analytic_derivation,kalman_algo=2,datafile=my_data,nobs=192,mh_replic=0,mh_nblocks=2,mh_jscale=0.8,plot_priors=0);
-estimation(order=1,mode_compute=4,mode_file=fs2000_analytic_derivation_mode,analytic_derivation,kalman_algo=1,datafile=my_data,nobs=192,mh_replic=0,mh_nblocks=2,mh_jscale=0.8,plot_priors=0);
-estimation(order=1,mode_compute=4,mode_file=fs2000_analytic_derivation_mode,analytic_derivation,kalman_algo=2,datafile=my_data,nobs=192,mh_replic=0,mh_nblocks=2,mh_jscale=0.8,plot_priors=0);
+estimation(order=1,mode_compute=5,mode_file='fs2000_analytic_derivation/Output/fs2000_analytic_derivation_mode',analytic_derivation,kalman_algo=2,datafile=my_data,nobs=192,mh_replic=0,mh_nblocks=2,mh_jscale=0.8,plot_priors=0);
+estimation(order=1,mode_compute=4,mode_file='fs2000_analytic_derivation/Output/fs2000_analytic_derivation_mode',analytic_derivation,kalman_algo=1,datafile=my_data,nobs=192,mh_replic=0,mh_nblocks=2,mh_jscale=0.8,plot_priors=0);
+estimation(order=1,mode_compute=4,mode_file='fs2000_analytic_derivation/Output/fs2000_analytic_derivation_mode',analytic_derivation,kalman_algo=2,datafile=my_data,nobs=192,mh_replic=0,mh_nblocks=2,mh_jscale=0.8,plot_priors=0);
 options_.debug=1;
-estimation(order=1,mode_compute=0,mode_file=fs2000_analytic_derivation_mode,analytic_derivation,kalman_algo=1,datafile=my_data,nobs=192,mh_replic=0,plot_priors=0);
+estimation(order=1,mode_compute=0,mode_file='fs2000_analytic_derivation/Output/fs2000_analytic_derivation_mode',analytic_derivation,kalman_algo=1,datafile=my_data,nobs=192,mh_replic=0,plot_priors=0);
 fval_Bayes_1=oo_.likelihood_at_initial_parameters;
-estimation(order=1,mode_compute=0,mode_file=fs2000_analytic_derivation_mode,analytic_derivation,kalman_algo=2,datafile=my_data,nobs=192,mh_replic=0,plot_priors=0);
+estimation(order=1,mode_compute=0,mode_file='fs2000_analytic_derivation/Output/fs2000_analytic_derivation_mode',analytic_derivation,kalman_algo=2,datafile=my_data,nobs=192,mh_replic=0,plot_priors=0);
 fval_Bayes_2=oo_.likelihood_at_initial_parameters;
 options_.analytic_derivation=0;
-estimation(order=1,mode_compute=0,mode_file=fs2000_analytic_derivation_mode,kalman_algo=1,datafile=my_data,nobs=192,mh_replic=0,plot_priors=0);
+estimation(order=1,mode_compute=0,mode_file='fs2000_analytic_derivation/Output/fs2000_analytic_derivation_mode',kalman_algo=1,datafile=my_data,nobs=192,mh_replic=0,plot_priors=0);
 fval_Bayes_3=oo_.likelihood_at_initial_parameters;
 
 if abs(fval_Bayes_1-fval_Bayes_2)>1e-5 || abs(fval_Bayes_1-fval_Bayes_3)>1e-5
diff --git a/tests/block_bytecode/lola_solve_one_boundary_mfs1.mod b/tests/block_bytecode/lola_solve_one_boundary_mfs1.mod
index 553171257d26babb89eed0970c6387159fa33b1d..64ff378bf7dd8e77775859a136d41eeb448c2d05 100644
--- a/tests/block_bytecode/lola_solve_one_boundary_mfs1.mod
+++ b/tests/block_bytecode/lola_solve_one_boundary_mfs1.mod
@@ -5,7 +5,7 @@
 @#define mfs = 1
 @#include "lola_common.inc"
 
-mfs0=load('lola_solve_one_boundary_results');
+mfs0=load(['lola_solve_one_boundary' filesep 'Output' filesep 'lola_solve_one_boundary_results']);
 
 if max(max(oo_.endo_simul-mfs0.oo_.endo_simul)) > options_.dynatol.x
    error('Inconsistency with mfs=0')
diff --git a/tests/block_bytecode/lola_solve_one_boundary_mfs2.mod b/tests/block_bytecode/lola_solve_one_boundary_mfs2.mod
index f582ecc8440f3064de4795c1addcc861786f0694..db5d379d593512b2c0659fa691f93619dac2f026 100644
--- a/tests/block_bytecode/lola_solve_one_boundary_mfs2.mod
+++ b/tests/block_bytecode/lola_solve_one_boundary_mfs2.mod
@@ -5,7 +5,7 @@
 @#define mfs = 2
 @#include "lola_common.inc"
 
-mfs0=load('lola_solve_one_boundary_results');
+mfs0=load(['lola_solve_one_boundary' filesep 'Output' filesep 'lola_solve_one_boundary_results']);
 
 if max(max(oo_.endo_simul-mfs0.oo_.endo_simul)) > options_.dynatol.x
    error('Inconsistency with mfs=0')
diff --git a/tests/block_bytecode/lola_solve_one_boundary_mfs3.mod b/tests/block_bytecode/lola_solve_one_boundary_mfs3.mod
index 3eb2dc9f0178f6cdeaa03407891c8d3126007e9b..16b227463ebe3590b848f41cbf8b323a9657cbbd 100644
--- a/tests/block_bytecode/lola_solve_one_boundary_mfs3.mod
+++ b/tests/block_bytecode/lola_solve_one_boundary_mfs3.mod
@@ -5,7 +5,7 @@
 @#define mfs = 3
 @#include "lola_common.inc"
 
-mfs0=load('lola_solve_one_boundary_results');
+mfs0=load(['lola_solve_one_boundary' filesep 'Output' filesep 'lola_solve_one_boundary_results']);
 
 if max(max(oo_.endo_simul-mfs0.oo_.endo_simul)) > options_.dynatol.x
    error('Inconsistency with mfs=0')
diff --git a/tests/block_bytecode/lola_stochastic_block.mod b/tests/block_bytecode/lola_stochastic_block.mod
index 5f6fff6b858a465e5d0a19ebf611ba1c9be38d10..954ecd4625251d1f3cd9b2076519f714aaf93e71 100644
--- a/tests/block_bytecode/lola_stochastic_block.mod
+++ b/tests/block_bytecode/lola_stochastic_block.mod
@@ -8,7 +8,7 @@
 
 [~, state_reorder] = sort(oo_.dr.state_var);
 
-ref = load('lola_stochastic_results.mat');
+ref = load(['lola_stochastic' filesep 'Output' filesep 'lola_stochastic_results.mat']);
 
 [~, ref_state_reorder] = sort(ref.oo_.dr.state_var);
 
diff --git a/tests/deterministic_simulations/multiple_lead_lags/ramst_augmented_histval.mod b/tests/deterministic_simulations/multiple_lead_lags/ramst_augmented_histval.mod
index 52aa9de85c5fd67b173169ae61e061328e0dd3d4..fb362e0dca89a676d26f3f012bd03d8b852ed325 100644
--- a/tests/deterministic_simulations/multiple_lead_lags/ramst_augmented_histval.mod
+++ b/tests/deterministic_simulations/multiple_lead_lags/ramst_augmented_histval.mod
@@ -70,7 +70,7 @@ if max(abs(junk(M_.maximum_lag+1:end)-oo_.endo_simul(strmatch('y_backward',M_.en
     error('Solution of purely backwards model not correct')
 end
         
-ramst_results=load('../../ramst_results.mat');
+ramst_results=load('../../ramst/Output/ramst_results.mat');
 if max(abs(ramst_results.oo_.endo_simul(strmatch('k',ramst_results.M_.endo_names,'exact'),1:end-M_.maximum_lead)-oo_.endo_simul(strmatch('k',M_.endo_names,'exact'),1:end-M_.maximum_lead)))>1e-10
     error('Solution of forward part of the model not correct')
 end
diff --git a/tests/deterministic_simulations/multiple_lead_lags/sim_endo_lead_lag.mod b/tests/deterministic_simulations/multiple_lead_lags/sim_endo_lead_lag.mod
index bf21b61498f853dae68ce272ce250848d8cad9b4..eedbad702124722140f37d0654a517d660a56883 100644
--- a/tests/deterministic_simulations/multiple_lead_lags/sim_endo_lead_lag.mod
+++ b/tests/deterministic_simulations/multiple_lead_lags/sim_endo_lead_lag.mod
@@ -44,7 +44,7 @@ if ~oo_.deterministic_simulation.status
    error('Perfect foresight simulation failed')
 end
 
-base_results=load('sim_base_results.mat');
+base_results=load(['sim_base' filesep 'Output' filesep 'sim_base_results.mat']);
 if max(abs(base_results.oo_.endo_simul(strmatch('c',base_results.M_.endo_names,'exact'),1+base_results.M_.maximum_endo_lag:end-base_results.M_.maximum_endo_lead) -...
     oo_.endo_simul(strmatch('c',M_.endo_names,'exact'),1+M_.maximum_endo_lag:end-M_.maximum_endo_lead)))>1e-8 || ...
     max(abs(base_results.oo_.endo_simul(strmatch('k',base_results.M_.endo_names,'exact'),1+base_results.M_.maximum_endo_lag:end-base_results.M_.maximum_endo_lead) -...
@@ -58,7 +58,7 @@ if max(abs(base_results.oo_.exo_simul(1:end-base_results.M_.maximum_lead-base_re
 end
 
 clear base_results;
-base_results_aux_vars=load('sim_endo_lead_lag_aux_vars_results.mat');
+base_results_aux_vars=load(['sim_exo_lead_lag_aux_vars' filesep 'Output' filesep 'sim_exo_lead_lag_aux_vars_results.mat']);
 if max(abs(base_results_aux_vars.oo_.endo_simul(strmatch('z_backward_lag_2',base_results_aux_vars.M_.endo_names,'exact'),1:end-base_results_aux_vars.M_.maximum_lead) -...
     oo_.endo_simul(strmatch('AUX_ENDO_LAG_2_2',M_.endo_names,'exact'),1:end-M_.maximum_lag)))>1e-8 
     error('Translation of endogenous variables is wrong')
diff --git a/tests/deterministic_simulations/multiple_lead_lags/sim_endo_lead_lag_aux_vars.mod b/tests/deterministic_simulations/multiple_lead_lags/sim_endo_lead_lag_aux_vars.mod
index 9c5a26f4da46dc46430e78e1ce99011dcda40a8b..d291d91815ba8273f53a02c92f1921ded2f63eb1 100644
--- a/tests/deterministic_simulations/multiple_lead_lags/sim_endo_lead_lag_aux_vars.mod
+++ b/tests/deterministic_simulations/multiple_lead_lags/sim_endo_lead_lag_aux_vars.mod
@@ -47,7 +47,7 @@ if ~oo_.deterministic_simulation.status
    error('Perfect foresight simulation failed')
 end
 
-base_results=load('sim_base_results.mat');
+base_results=load(['sim_base' filesep 'Output' filesep 'sim_base_results.mat']);
 if max(abs(base_results.oo_.endo_simul(strmatch('c',base_results.M_.endo_names,'exact'),1+base_results.M_.maximum_endo_lag:end-base_results.M_.maximum_endo_lead) -...
     oo_.endo_simul(strmatch('c',M_.endo_names,'exact'),1+M_.maximum_endo_lag:end-M_.maximum_endo_lead)))>1e-8 || ...
     max(abs(base_results.oo_.endo_simul(strmatch('k',base_results.M_.endo_names,'exact'),1+base_results.M_.maximum_endo_lag:end-base_results.M_.maximum_endo_lead) -...
diff --git a/tests/deterministic_simulations/multiple_lead_lags/sim_exo_lead_lag.mod b/tests/deterministic_simulations/multiple_lead_lags/sim_exo_lead_lag.mod
index fa0c3d384e21d57bbe2c69dc91d55e071b80e9bb..d84479a45e1c9fd2bed6f36026845c9a738e4ca6 100644
--- a/tests/deterministic_simulations/multiple_lead_lags/sim_exo_lead_lag.mod
+++ b/tests/deterministic_simulations/multiple_lead_lags/sim_exo_lead_lag.mod
@@ -42,7 +42,7 @@ if ~oo_.deterministic_simulation.status
    error('Perfect foresight simulation failed')
 end
 
-base_results=load('sim_base_results.mat');
+base_results=load(['sim_base' filesep 'Output' filesep 'sim_base_results.mat']);
 if max(abs(base_results.oo_.endo_simul(strmatch('c',base_results.M_.endo_names,'exact'),1+base_results.M_.maximum_endo_lag:end-base_results.M_.maximum_endo_lead) -...
     oo_.endo_simul(strmatch('c',M_.endo_names,'exact'),1+M_.maximum_lag:end-M_.maximum_lead)))>1e-8 || ...
     max(abs(base_results.oo_.endo_simul(strmatch('k',base_results.M_.endo_names,'exact'),1+base_results.M_.maximum_endo_lag:end-base_results.M_.maximum_endo_lead) -...
@@ -51,7 +51,7 @@ if max(abs(base_results.oo_.endo_simul(strmatch('c',base_results.M_.endo_names,'
 end
 
 clear base_results
-base_results_aux_vars=load('sim_exo_lead_lag_aux_vars_results.mat');
+base_results_aux_vars=load(['sim_exo_lead_lag_aux_vars' filesep 'Output' filesep 'sim_exo_lead_lag_aux_vars_results.mat']);
 
 if max(abs(base_results_aux_vars.oo_.endo_simul(strmatch('x_lag_3',base_results_aux_vars.M_.endo_names,'exact'),base_results_aux_vars.M_.maximum_lag+3:end-base_results_aux_vars.M_.maximum_lead)' -...
     oo_.exo_simul(M_.maximum_lag:end-M_.maximum_lead-3,strmatch('x', M_.exo_names, 'exact'))))>1e-8
diff --git a/tests/deterministic_simulations/multiple_lead_lags/sim_exo_lead_lag_aux_vars.mod b/tests/deterministic_simulations/multiple_lead_lags/sim_exo_lead_lag_aux_vars.mod
index 0cf9342aeb96c0fec215b2e98a8f5e2baf43d7b1..113812b5d957116c44a3db759cf725a63332e0f5 100644
--- a/tests/deterministic_simulations/multiple_lead_lags/sim_exo_lead_lag_aux_vars.mod
+++ b/tests/deterministic_simulations/multiple_lead_lags/sim_exo_lead_lag_aux_vars.mod
@@ -47,7 +47,7 @@ if ~oo_.deterministic_simulation.status
    error('Perfect foresight simulation failed')
 end
 
-base_results=load('sim_base_results.mat');
+base_results=load(['sim_base' filesep 'Output' filesep 'sim_base_results.mat']);
 if max(abs(base_results.oo_.endo_simul(strmatch('c',base_results.M_.endo_names,'exact'),1+base_results.M_.maximum_endo_lag:end-base_results.M_.maximum_endo_lead) -...
     oo_.endo_simul(strmatch('c',M_.endo_names,'exact'),1+M_.maximum_endo_lag:end-M_.maximum_endo_lead)))>1e-8 || ...
     max(abs(base_results.oo_.endo_simul(strmatch('k',base_results.M_.endo_names,'exact'),1+base_results.M_.maximum_endo_lag:end-base_results.M_.maximum_endo_lead) -...
diff --git a/tests/deterministic_simulations/multiple_lead_lags/sim_lead_lag.mod b/tests/deterministic_simulations/multiple_lead_lags/sim_lead_lag.mod
index d39ce7c7b859d8e945413ca56b18932af430f122..8187405455483ecd3244221deee72bb4d5b45c8c 100644
--- a/tests/deterministic_simulations/multiple_lead_lags/sim_lead_lag.mod
+++ b/tests/deterministic_simulations/multiple_lead_lags/sim_lead_lag.mod
@@ -46,7 +46,7 @@ if ~oo_.deterministic_simulation.status
    error('Perfect foresight simulation failed')
 end
 
-base_results=load('sim_base_results.mat');
+base_results=load(['sim_base' filesep 'Output' filesep 'sim_base_results.mat']);
 if max(abs(base_results.oo_.endo_simul(strmatch('c',base_results.M_.endo_names,'exact'),1+base_results.M_.maximum_endo_lag:end-base_results.M_.maximum_endo_lead) -...
     oo_.endo_simul(strmatch('c',M_.endo_names,'exact'),1+M_.maximum_lag:end-M_.maximum_lead)))>1e-8 || ...
     max(abs(base_results.oo_.endo_simul(strmatch('k',base_results.M_.endo_names,'exact'),1+base_results.M_.maximum_endo_lag:end-base_results.M_.maximum_endo_lead) -...
@@ -55,7 +55,7 @@ if max(abs(base_results.oo_.endo_simul(strmatch('c',base_results.M_.endo_names,'
 end
 
 clear base_results
-base_results_aux_vars=load('sim_lead_lag_aux_vars_results.mat');
+base_results_aux_vars=load(['sim_exo_lead_lag_aux_vars' filesep 'Output' filesep 'sim_exo_lead_lag_aux_vars_results.mat']);
 
 if max(abs(base_results_aux_vars.oo_.endo_simul(strmatch('x_lag_3',base_results_aux_vars.M_.endo_names,'exact'),base_results_aux_vars.M_.maximum_lag+3:end-base_results_aux_vars.M_.maximum_lead)' -...
     oo_.exo_simul(M_.maximum_lag:end-M_.maximum_lead-3,strmatch('x', M_.exo_names, 'exact'))))>1e-8
diff --git a/tests/deterministic_simulations/multiple_lead_lags/sim_lead_lag_aux_vars.mod b/tests/deterministic_simulations/multiple_lead_lags/sim_lead_lag_aux_vars.mod
index a09c0d0e646a2ef00ebc299e3c3292de44af1390..b35cacd458cc4d0261d9d7add01edbe8fea0a720 100644
--- a/tests/deterministic_simulations/multiple_lead_lags/sim_lead_lag_aux_vars.mod
+++ b/tests/deterministic_simulations/multiple_lead_lags/sim_lead_lag_aux_vars.mod
@@ -57,7 +57,7 @@ if ~oo_.deterministic_simulation.status
    error('Perfect foresight simulation failed')
 end
 
-base_results=load('sim_base_results.mat');
+base_results=load(['sim_base' filesep 'Output' filesep 'sim_base_results.mat']);
 if max(abs(base_results.oo_.endo_simul(strmatch('c',base_results.M_.endo_names,'exact'),1+base_results.M_.maximum_endo_lag:end-base_results.M_.maximum_endo_lead) -...
     oo_.endo_simul(strmatch('c',M_.endo_names,'exact'),1+M_.maximum_endo_lag:end-M_.maximum_endo_lead)))>1e-8 || ...
     max(abs(base_results.oo_.endo_simul(strmatch('k',base_results.M_.endo_names,'exact'),1+base_results.M_.maximum_endo_lag:end-base_results.M_.maximum_endo_lead) -...
diff --git a/tests/deterministic_simulations/rbc_det_exo_lag_2b.mod b/tests/deterministic_simulations/rbc_det_exo_lag_2b.mod
index 8965fc18f1ddafee9f9bc457c1482ad1c828f6dc..60e7e7cc5d4fa7ce427c754b76537ec6498489a2 100644
--- a/tests/deterministic_simulations/rbc_det_exo_lag_2b.mod
+++ b/tests/deterministic_simulations/rbc_det_exo_lag_2b.mod
@@ -79,6 +79,6 @@ end
 rplot Consumption;
 rplot Capital;
 
-O=load('rbc_det_exo_lag_2a_results');
+O=load(['rbc_det_exo_lag_2a' filesep 'Output' filesep 'rbc_det_exo_lag_2a_results']);
 
 fataltest(oo_.endo_simul(1:M_.orig_endo_nbr,:),O.oo_.endo_simul(1:O.M_.orig_endo_nbr,:),1);
diff --git a/tests/deterministic_simulations/rbc_det_exo_lag_2c.mod b/tests/deterministic_simulations/rbc_det_exo_lag_2c.mod
index a1b5c2ae0dd8a2c6ffd1679f9780c4c0a333c372..75e44854c8ff2beb8a96c3e24eccd97c4b3c72c0 100644
--- a/tests/deterministic_simulations/rbc_det_exo_lag_2c.mod
+++ b/tests/deterministic_simulations/rbc_det_exo_lag_2c.mod
@@ -79,6 +79,6 @@ end
 rplot Consumption;
 rplot Capital;
 
-O=load('rbc_det_exo_lag_2a_results');
+O=load(['rbc_det_exo_lag_2a' filesep 'Output' filesep 'rbc_det_exo_lag_2a_results']);
 
 fataltest(oo_.endo_simul(1:M_.orig_endo_nbr,:),O.oo_.endo_simul(1:O.M_.orig_endo_nbr,:),1);
diff --git a/tests/deterministic_simulations/rbc_det_stack_solve_algo_7.mod b/tests/deterministic_simulations/rbc_det_stack_solve_algo_7.mod
index a4c829ffb37d6102c2ff238544b60c863d9a43d1..aec2adb46c8d36cb9e272a1157cfff36c4139705 100644
--- a/tests/deterministic_simulations/rbc_det_stack_solve_algo_7.mod
+++ b/tests/deterministic_simulations/rbc_det_stack_solve_algo_7.mod
@@ -81,7 +81,7 @@ end
 rplot Consumption;
 rplot Capital;
 
-D = load('rbc_det_results');
+D = load(['rbc_det' filesep 'Output' filesep 'rbc_det_results']);
 
 if norm(D.oo_.endo_simul - oo_.endo_simul) > 1e-30;
    disp(norm(D.oo_.endo_simul - oo_.endo_simul));
@@ -102,7 +102,7 @@ end
 rplot Consumption;
 rplot Capital;
 
-D = load('rbc_det_results');
+D = load(['rbc_det' filesep 'Output' filesep 'rbc_det_results']);
 if isoctave && options_.solve_algo==0
     %%acount for somehow weaker convergence criterion in Octave's fsolve
     tol_crit=1e-4;
diff --git a/tests/deterministic_simulations/rbc_det_stack_solve_algo_7_exo_lag.mod b/tests/deterministic_simulations/rbc_det_stack_solve_algo_7_exo_lag.mod
index e449069044671b0677128cbcde38d533f2c56052..3c35acebd43e6d41ec06877c04f32ef161248953 100644
--- a/tests/deterministic_simulations/rbc_det_stack_solve_algo_7_exo_lag.mod
+++ b/tests/deterministic_simulations/rbc_det_stack_solve_algo_7_exo_lag.mod
@@ -81,7 +81,7 @@ end
 rplot Consumption;
 rplot Capital;
 
-D = load('rbc_det_results');
+D = load(['rbc_det' filesep 'Output' filesep 'rbc_det_results']);
 
 if norm(D.oo_.endo_simul(1:D.M_.orig_endo_nbr,D.M_.maximum_lag+1:end-D.M_.maximum_lead) - oo_.endo_simul(1:M_.orig_endo_nbr,M_.maximum_lag+1:end-M_.maximum_lead)) > 1e-30;
    disp(D.oo_.endo_simul(1:D.M_.orig_endo_nbr,D.M_.maximum_lag+1:end-D.M_.maximum_lead) - oo_.endo_simul(1:M_.orig_endo_nbr,M_.maximum_lag+1:end-M_.maximum_lead));
@@ -102,7 +102,7 @@ end
 rplot Consumption;
 rplot Capital;
 
-D = load('rbc_det_results');
+D = load(['rbc_det' filesep 'Output' filesep 'rbc_det_results']);
 if isoctave && options_.solve_algo==0
     %%acount for somehow weaker convergence criterion in Octave's fsolve
     tol_crit=1e-4;
diff --git a/tests/deterministic_simulations/rbc_det_stack_solve_algo_7_exo_lead.mod b/tests/deterministic_simulations/rbc_det_stack_solve_algo_7_exo_lead.mod
index 9d649d90236d68457ce6c76016147187bff694d1..60b969a688310582ca57439929d680190845e80f 100644
--- a/tests/deterministic_simulations/rbc_det_stack_solve_algo_7_exo_lead.mod
+++ b/tests/deterministic_simulations/rbc_det_stack_solve_algo_7_exo_lead.mod
@@ -81,7 +81,7 @@ end
 rplot Consumption;
 rplot Capital;
 
-D = load('rbc_det_results');
+D = load(['rbc_det' filesep 'Output' filesep 'rbc_det_results']);
 
 if norm(D.oo_.endo_simul(1:D.M_.orig_endo_nbr,D.M_.maximum_lag+1:end-D.M_.maximum_lead) - oo_.endo_simul(1:M_.orig_endo_nbr,M_.maximum_lag+1:end-M_.maximum_lead)) > 1e-30;
    disp(D.oo_.endo_simul(1:D.M_.orig_endo_nbr,D.M_.maximum_lag+1:end-D.M_.maximum_lead) - oo_.endo_simul(1:M_.orig_endo_nbr,M_.maximum_lag+1:end-M_.maximum_lead));
@@ -102,7 +102,7 @@ end
 rplot Consumption;
 rplot Capital;
 
-D = load('rbc_det_results');
+D = load(['rbc_det' filesep 'Output' filesep 'rbc_det_results']);
 if isoctave && options_.solve_algo==0
     %%acount for somehow weaker convergence criterion in Octave's fsolve
     tol_crit=1e-4;
diff --git a/tests/discretionary_policy/Gali_2015_chapter_3_nonlinear.mod b/tests/discretionary_policy/Gali_2015_chapter_3_nonlinear.mod
index 26ecf95d73565449ff75f63027cbfe684dd8f5e7..ca76e30335cb134998dbc868a2d3d0433b0f8e72 100644
--- a/tests/discretionary_policy/Gali_2015_chapter_3_nonlinear.mod
+++ b/tests/discretionary_policy/Gali_2015_chapter_3_nonlinear.mod
@@ -219,7 +219,7 @@ end;
 planner_objective 0.5*((siggma+(varphi+alppha)/(1-alppha))*y_hat^2+epsilon/0.0215*pi^2)/100;
 discretionary_policy(order=1,instruments=(R),irf=20,planner_discount=betta, periods=0) y_hat pi_ann log_y log_N log_W_real log_P;
 
-temp=load('Gali_2015_chapter_3_results.mat');
+temp=load(['Gali_2015_chapter_3' filesep 'Output' filesep 'Gali_2015_chapter_3_results.mat']);
 if abs(oo_.planner_objective_value-temp.oo_.planner_objective_value)>1e-6
     warning('Planner objective does not match linear model')
 end
diff --git a/tests/estimation/MH_recover/fs2000_recover.mod b/tests/estimation/MH_recover/fs2000_recover.mod
index 7a55782f600da309c2c79091443bb1293d8d6295..5b551e8d2e36b6790c3fdf708787e63d1196a436 100644
--- a/tests/estimation/MH_recover/fs2000_recover.mod
+++ b/tests/estimation/MH_recover/fs2000_recover.mod
@@ -8,7 +8,7 @@ copyfile([M_.dname filesep 'metropolis' filesep M_.dname '_mh1_blck1.mat'],[M_.d
 copyfile([M_.dname filesep 'metropolis' filesep M_.dname '_mh2_blck2.mat'],[M_.dname '_mh2_blck2.mat'])
 delete([M_.dname filesep 'metropolis' filesep M_.dname '_mh2_blck2.mat'])
 
-estimation(order=1, datafile='../fsdat_simul',mode_compute=0,mode_file=fs2000_recover_mode, nobs=192, loglinear, mh_replic=2000, mh_nblocks=2, mh_jscale=0.8,mh_recover);
+estimation(order=1, datafile='../fsdat_simul',mode_compute=0,mode_file='fs2000_recover/Output/fs2000_recover_mode', nobs=192, loglinear, mh_replic=2000, mh_nblocks=2, mh_jscale=0.8,mh_recover);
 
 %check first unaffected chain
 temp1=load([M_.dname '_mh1_blck1.mat']);
diff --git a/tests/estimation/MH_recover/fs2000_recover_2.mod b/tests/estimation/MH_recover/fs2000_recover_2.mod
index 11800bcb9c2fe0d31f98666acf256fe6b56ae818..cb70cd1c9d0bfecf02e19098eda57ee4ea18be29 100644
--- a/tests/estimation/MH_recover/fs2000_recover_2.mod
+++ b/tests/estimation/MH_recover/fs2000_recover_2.mod
@@ -5,7 +5,7 @@
 
 options_.MaxNumberOfBytes=2000*11*8/4;
 estimation(order=1, datafile='../fsdat_simul',nobs=192, loglinear, mh_replic=999, mh_nblocks=2, mh_jscale=0.8);
-estimation(order=1,mode_compute=0,mode_file=fs2000_recover_2_mode, datafile='../fsdat_simul',nobs=192, loglinear, load_mh_file,mh_replic=1002, mh_nblocks=2, mh_jscale=0.8);
+estimation(order=1,mode_compute=0,mode_file='fs2000_recover_2/Output/fs2000_recover_2_mode', datafile='../fsdat_simul',nobs=192, loglinear, load_mh_file,mh_replic=1002, mh_nblocks=2, mh_jscale=0.8);
 copyfile([M_.dname filesep 'metropolis' filesep M_.dname '_mh1_blck1.mat'],[M_.dname '_mh1_blck1.mat'])
 copyfile([M_.dname filesep 'metropolis' filesep M_.dname '_mh3_blck2.mat'],[M_.dname '_mh3_blck2.mat'])
 copyfile([M_.dname filesep 'metropolis' filesep M_.dname '_mh4_blck2.mat'],[M_.dname '_mh4_blck2.mat'])
@@ -14,7 +14,7 @@ delete([M_.dname filesep 'metropolis' filesep M_.dname '_mh3_blck2.mat'])
 delete([M_.dname filesep 'metropolis' filesep M_.dname '_mh4_blck2.mat'])
 delete([M_.dname filesep 'metropolis' filesep M_.dname '_mh5_blck2.mat'])
 
-estimation(order=1, datafile='../fsdat_simul',mode_compute=0,mode_file=fs2000_recover_2_mode, nobs=192, loglinear, mh_replic=2000, mh_nblocks=2, mh_jscale=0.8,mh_recover);
+estimation(order=1, datafile='../fsdat_simul',mode_compute=0,mode_file='fs2000_recover_2/Output/fs2000_recover_2_mode', nobs=192, loglinear, mh_replic=2000, mh_nblocks=2, mh_jscale=0.8,mh_recover);
 
 %check first unaffected chain
 temp1=load([M_.dname '_mh1_blck1.mat']);
diff --git a/tests/estimation/MH_recover/fs2000_recover_3.mod b/tests/estimation/MH_recover/fs2000_recover_3.mod
index ac01b4bb2b09220af6e8b2175d08f709a656423a..ecf0592d4796bc60b1eb738f26fcf248c98a1f84 100644
--- a/tests/estimation/MH_recover/fs2000_recover_3.mod
+++ b/tests/estimation/MH_recover/fs2000_recover_3.mod
@@ -5,14 +5,14 @@
 
 options_.MaxNumberOfBytes=2000*11*8/4;
 estimation(order=1, datafile='../fsdat_simul',nobs=192, loglinear, mh_replic=1000, mh_nblocks=2, mh_jscale=0.8);
-estimation(order=1,mode_compute=0,mode_file=fs2000_recover_3_mode, datafile='../fsdat_simul',nobs=192, loglinear, load_mh_file,mh_replic=1000, mh_nblocks=2, mh_jscale=0.8);
+estimation(order=1,mode_compute=0,mode_file='fs2000_recover_3/Output/fs2000_recover_3_mode', datafile='../fsdat_simul',nobs=192, loglinear, load_mh_file,mh_replic=1000, mh_nblocks=2, mh_jscale=0.8);
 copyfile([M_.dname filesep 'metropolis' filesep M_.dname '_mh1_blck1.mat'],[M_.dname '_mh1_blck1.mat'])
 copyfile([M_.dname filesep 'metropolis' filesep M_.dname '_mh3_blck2.mat'],[M_.dname '_mh3_blck2.mat'])
 copyfile([M_.dname filesep 'metropolis' filesep M_.dname '_mh4_blck2.mat'],[M_.dname '_mh4_blck2.mat'])
 delete([M_.dname filesep 'metropolis' filesep M_.dname '_mh3_blck2.mat'])
 delete([M_.dname filesep 'metropolis' filesep M_.dname '_mh4_blck2.mat'])
 
-estimation(order=1, datafile='../fsdat_simul',mode_compute=0,mode_file=fs2000_recover_3_mode, nobs=192, loglinear, mh_replic=2000, mh_nblocks=2, mh_jscale=0.8,mh_recover);
+estimation(order=1, datafile='../fsdat_simul',mode_compute=0,mode_file='fs2000_recover_3/Output/fs2000_recover_3_mode', nobs=192, loglinear, mh_replic=2000, mh_nblocks=2, mh_jscale=0.8,mh_recover);
 
 %check first unaffected chain
 temp1=load([M_.dname '_mh1_blck1.mat']);
diff --git a/tests/estimation/MH_recover/fs2000_recover_tarb.mod b/tests/estimation/MH_recover/fs2000_recover_tarb.mod
index 4d3d9ee7334a65757f472622cc0d09091be424dc..ea4cb4520005d96330e34da4cffd5ec6555fe6f1 100644
--- a/tests/estimation/MH_recover/fs2000_recover_tarb.mod
+++ b/tests/estimation/MH_recover/fs2000_recover_tarb.mod
@@ -8,7 +8,7 @@ copyfile([M_.dname filesep 'metropolis' filesep M_.dname '_mh1_blck1.mat'],[M_.d
 copyfile([M_.dname filesep 'metropolis' filesep M_.dname '_mh2_blck2.mat'],[M_.dname '_mh2_blck2.mat'])
 delete([M_.dname filesep 'metropolis' filesep M_.dname '_mh2_blck2.mat'])
 
-estimation(posterior_sampling_method='tailored_random_block_metropolis_hastings',order=1, datafile='../fsdat_simul',mode_compute=0,mode_file=fs2000_recover_mode, nobs=192, loglinear, mh_replic=2000, mh_nblocks=2, mh_jscale=0.8,mh_recover);
+estimation(posterior_sampling_method='tailored_random_block_metropolis_hastings',order=1, datafile='../fsdat_simul',mode_compute=0,mode_file='fs2000_recover/Output/fs2000_recover_mode', nobs=192, loglinear, mh_replic=2000, mh_nblocks=2, mh_jscale=0.8,mh_recover);
 
 %check first unaffected chain
 temp1=load([M_.dname '_mh1_blck1.mat']);
diff --git a/tests/estimation/fs2000.mod b/tests/estimation/fs2000.mod
index 4ab6d4ad68654c4b26ae7c741c0f0fd819da0cb2..f12c8d9b036dadaae794473d609a54d881cb58ec 100644
--- a/tests/estimation/fs2000.mod
+++ b/tests/estimation/fs2000.mod
@@ -104,11 +104,11 @@ options_.smoother=0;
 options_.moments_varendo=0;
 options_.forecast=0;   
 copyfile([M_.dname filesep 'metropolis' filesep M_.dname '_mh1_blck1.mat'],[M_.dname '_mh1_blck1.mat'])
-estimation(mode_compute=0,mode_file=fs2000_mode,order=1, datafile=fsdat_simul, nobs=192, loglinear, mh_replic=1500, mh_nblocks=1, mh_jscale=0.8);
+estimation(mode_compute=0,mode_file='fs2000/Output/fs2000_mode',order=1, datafile=fsdat_simul, nobs=192, loglinear, mh_replic=1500, mh_nblocks=1, mh_jscale=0.8);
 hh=eye(size(bayestopt_.name,1));
-save('fs2000_mode.mat','hh','-append')
+save('fs2000/Output/fs2000_mode.mat','hh','-append')
 Laplace = oo_.MarginalDensity.LaplaceApproximation; %save Laplace approximation which will be overwritten with set hh otherwise
-estimation(mode_compute=0,mode_file=fs2000_mode,order=1, datafile=fsdat_simul, nobs=192, loglinear, mh_replic=1500, mh_nblocks=1, mh_jscale=10,load_mh_file);
+estimation(mode_compute=0,mode_file='fs2000/Output/fs2000_mode',order=1, datafile=fsdat_simul, nobs=192, loglinear, mh_replic=1500, mh_nblocks=1, mh_jscale=10,load_mh_file);
 
 temp1=load([M_.dname '_mh1_blck1.mat']);
 temp2=load([M_.dname filesep 'metropolis' filesep M_.dname '_mh1_blck1.mat']);
@@ -121,7 +121,7 @@ end
         
 save('fs2000_result.mat','oo_')        
 options_.load_results_after_load_mh=1;
-estimation(mode_compute=0,mode_file=fs2000_mode,order=1, datafile=fsdat_simul, nobs=192, loglinear, mh_replic=0, mh_nblocks=1, mh_jscale=10,load_mh_file,smoother) gy_obs gp_obs;
+estimation(mode_compute=0,mode_file='fs2000/Output/fs2000_mode',order=1, datafile=fsdat_simul, nobs=192, loglinear, mh_replic=0, mh_nblocks=1, mh_jscale=10,load_mh_file,smoother) gy_obs gp_obs;
 oo_.MarginalDensity.LaplaceApproximation = Laplace; %reset correct Laplace
 
 
diff --git a/tests/estimation/fs2000_MCMC_jumping_covariance.mod b/tests/estimation/fs2000_MCMC_jumping_covariance.mod
index 91a6f20d86fc92f30733c33c2da2836df81e93b8..423ac91f971f40dbf56ad8cff59e700eefae7e58 100644
--- a/tests/estimation/fs2000_MCMC_jumping_covariance.mod
+++ b/tests/estimation/fs2000_MCMC_jumping_covariance.mod
@@ -84,9 +84,9 @@ options_.mode_compute=4;
 options_.plot_priors=0;
 estimation(order=1,datafile=fsdat_simul,nobs=192,loglinear,mh_replic=1000,mh_nblocks=1,mh_jscale=0.8,mcmc_jumping_covariance=hessian);
 
-load fs2000_MCMC_jumping_covariance_mode hh;
+load('fs2000_MCMC_jumping_covariance/Output/fs2000_MCMC_jumping_covariance_mode','hh');
 jumping_covariance=diag(diag(hh));
-save test_matrix.mat jumping_covariance;
+save('test_matrix.mat','jumping_covariance');
 
 estimation(order=1,datafile=fsdat_simul,nobs=192,loglinear,mh_replic=1000,mh_nblocks=1,mh_jscale=0.01,mcmc_jumping_covariance=prior_variance);
 estimation(order=1,datafile=fsdat_simul,nobs=192,loglinear,mh_replic=1000,mh_nblocks=1,mh_jscale=0.0001,mcmc_jumping_covariance=identity_matrix);
diff --git a/tests/estimation/heteroskedastic_shocks/fs2000_het.mod b/tests/estimation/heteroskedastic_shocks/fs2000_het.mod
index 2aa16d50556b2b1b974c0e98da4031d671f460b7..a0974c92c8d83b525f0aced13713a22c128ba725 100644
--- a/tests/estimation/heteroskedastic_shocks/fs2000_het.mod
+++ b/tests/estimation/heteroskedastic_shocks/fs2000_het.mod
@@ -29,5 +29,5 @@ end;
 
 estimation(order=1,datafile='../fsdat_simul',nobs=192,mode_compute=5,loglinear,mh_replic=0,smoother,filtered_vars,forecast=8,filter_step_ahead=[1:8],consider_all_endogenous,heteroskedastic_filter);
 
-@#define mode_file_name="fs2000_het_mode"
+@#define mode_file_name="'fs2000_het/Output/fs2000_het_mode'"
 @#include "fs2000_het_check.inc"
diff --git a/tests/estimation/heteroskedastic_shocks/fs2000_het_corr.mod b/tests/estimation/heteroskedastic_shocks/fs2000_het_corr.mod
index f0887ea708d4be7a091a88e3f1e82d46ec250704..dae222e46aaa4d49bafabdab2b30f8f59bdfae04 100644
--- a/tests/estimation/heteroskedastic_shocks/fs2000_het_corr.mod
+++ b/tests/estimation/heteroskedastic_shocks/fs2000_het_corr.mod
@@ -33,5 +33,5 @@ end;
 
 estimation(order=1,datafile='../fsdat_simul',nobs=192,mode_compute=5,loglinear,mh_replic=0,smoother,filtered_vars,forecast=8,filter_step_ahead=[1:8],consider_all_endogenous,heteroskedastic_filter);
 
-@#define mode_file_name="fs2000_het_corr_mode"
+@#define mode_file_name="'fs2000_het_corr/Output/fs2000_het_corr_mode'"
 @#include "fs2000_het_check.inc" 
diff --git a/tests/example1_use_dll.mod b/tests/example1_use_dll.mod
index 66bbe7c5c8a6e89340d29315492f7c9bd49108ac..8c5b200d6d5df10d307ec946af233bb0fda34b59 100644
--- a/tests/example1_use_dll.mod
+++ b/tests/example1_use_dll.mod
@@ -44,11 +44,11 @@ end;
 
 stoch_simul(nograph);
 
-if ~exist('example1_results.mat','file');
+if ~exist(['example1' filesep 'Output' filesep 'example1_results.mat'],'file');
    error('example1 must be run first');
 end;
 
-oo1 = load('example1_results','oo_');
+oo1 = load(['example1' filesep 'Output' filesep 'example1_results'],'oo_');
 
 dr0 = oo1.oo_.dr;
 dr = oo_.dr;
diff --git a/tests/example2long.mod b/tests/example2long.mod
index bdaec0050b265993eec661a6a2f2edc875a4df54..f68bd608a5d04b9e42626cf2fb485fb14deb3286 100644
--- a/tests/example2long.mod
+++ b/tests/example2long.mod
@@ -51,11 +51,11 @@ end;
 
 stoch_simul;
 
-if ~exist('example1long_results.mat','file');
+if ~exist(['example1long' filesep 'Output' filesep 'example1long_results.mat'],'file');
    error('example1long must be run first');
 end;
 
-oo1 = load('example1long_results','oo_');
+oo1 = load(['example1long' filesep 'Output' filesep 'example1long_results'],'oo_');
 
 dr0 = oo1.oo_.dr;
 dr = oo_.dr;
diff --git a/tests/example2long_use_dll.mod b/tests/example2long_use_dll.mod
index b0a28fa01111b63d12fbfffbc1dd416a52488173..0dab99e81d29579a3da563aa89198f458057ac90 100644
--- a/tests/example2long_use_dll.mod
+++ b/tests/example2long_use_dll.mod
@@ -51,11 +51,12 @@ end;
 
 stoch_simul;
 
-if ~exist('example1long_results.mat','file');
+if ~exist(['example1long' filesep 'Output' filesep 'example1long_results.mat'],'file');
    error('example1long must be run first');
 end;
 
-oo1 = load('example1long_results','oo_');
+oo1 = load(['example1long' filesep 'Output' filesep 'example1long_results'],'oo_');
+
 
 dr0 = oo1.oo_.dr;
 dr = oo_.dr;
diff --git a/tests/external_function/extfun_in_mlv.mod b/tests/external_function/extfun_in_mlv.mod
index 1b2947cff521b1431477e1e7ccb6a83a0c656d5a..bed024d0f60fafc825f9ec04243ebbe3c05a9b5b 100644
--- a/tests/external_function/extfun_in_mlv.mod
+++ b/tests/external_function/extfun_in_mlv.mod
@@ -46,7 +46,7 @@ end;
 
 stoch_simul;
 
-L = load('benchmark_results.mat');
+L = load(['benchmark' filesep 'Output' filesep 'benchmark_results.mat']);
 if max(max(abs(L.oo_.dr.ghu - oo_.dr.ghu))) > 1e-12
   error('Failure in external function')
 end
diff --git a/tests/external_function/first_and_2nd_deriv_given.mod b/tests/external_function/first_and_2nd_deriv_given.mod
index f62110442842ae49ef4e062237dc4abaa05433f6..d4395ae5389703d7edd57370030b8f527335968a 100644
--- a/tests/external_function/first_and_2nd_deriv_given.mod
+++ b/tests/external_function/first_and_2nd_deriv_given.mod
@@ -45,7 +45,7 @@ end;
 
 stoch_simul;
 
-L = load('benchmark_results.mat');
+L = load(['benchmark' filesep 'Output' filesep 'benchmark_results.mat']);
 if max(max(abs(L.oo_.dr.ghu - oo_.dr.ghu))) > 1e-12
   error('Failure in external function')
 end
diff --git a/tests/external_function/first_and_2nd_deriv_given_dll.mod b/tests/external_function/first_and_2nd_deriv_given_dll.mod
index ac42623c6fc54980704f75ed7c1d974cedee9991..328b2e6928e1ed5c05ee0afa2ec105ed57ab32a4 100644
--- a/tests/external_function/first_and_2nd_deriv_given_dll.mod
+++ b/tests/external_function/first_and_2nd_deriv_given_dll.mod
@@ -45,7 +45,7 @@ end;
 
 stoch_simul;
 
-L = load('benchmark_results.mat');
+L = load(['benchmark' filesep 'Output' filesep 'benchmark_results.mat']);
 if max(max(abs(L.oo_.dr.ghu - oo_.dr.ghu))) > 1e-12
   error('Failure in external function')
 end
diff --git a/tests/external_function/first_and_2nd_deriv_given_dll_namespace.mod b/tests/external_function/first_and_2nd_deriv_given_dll_namespace.mod
index ca55aea5a94e37f97478a662e4d18c025ccdec15..5af21e14da4460582e351bf4d7e07690aecd80c7 100644
--- a/tests/external_function/first_and_2nd_deriv_given_dll_namespace.mod
+++ b/tests/external_function/first_and_2nd_deriv_given_dll_namespace.mod
@@ -47,7 +47,7 @@ end;
 
 stoch_simul;
 
-L = load('benchmark_results.mat');
+L = load(['benchmark' filesep 'Output' filesep 'benchmark_results.mat']);
 if max(max(abs(L.oo_.dr.ghu - oo_.dr.ghu))) > 1e-12
   error('Failure in external function')
 end
diff --git a/tests/external_function/first_and_2nd_deriv_given_namespace.mod b/tests/external_function/first_and_2nd_deriv_given_namespace.mod
index 3729a17d66bcc037dfefa3505db676e30c8c4ac8..cc42dc296f18339b354e23dd51c2e6a01fda8bea 100644
--- a/tests/external_function/first_and_2nd_deriv_given_namespace.mod
+++ b/tests/external_function/first_and_2nd_deriv_given_namespace.mod
@@ -47,7 +47,7 @@ end;
 
 stoch_simul;
 
-L = load('benchmark_results.mat');
+L = load(['benchmark' filesep 'Output' filesep 'benchmark_results.mat']);
 if max(max(abs(L.oo_.dr.ghu - oo_.dr.ghu))) > 1e-12
   error('Failure in external function')
 end
diff --git a/tests/external_function/first_deriv_given.mod b/tests/external_function/first_deriv_given.mod
index ef7ba0ab4fab68ddc4e96cea083c68ed410ffa57..4262a29a1a83fb4ba129a54ce2b321feee0e98aa 100644
--- a/tests/external_function/first_deriv_given.mod
+++ b/tests/external_function/first_deriv_given.mod
@@ -45,7 +45,7 @@ end;
 
 stoch_simul;
 
-L = load('benchmark_results.mat');
+L = load(['benchmark' filesep 'Output' filesep 'benchmark_results.mat']);
 if max(max(abs(L.oo_.dr.ghu - oo_.dr.ghu))) > 1e-12
   error('Failure in external function')
 end
diff --git a/tests/external_function/first_deriv_given_dll.mod b/tests/external_function/first_deriv_given_dll.mod
index cfaf4ae519635b4a9b39a88ffc63189b34c57050..6f4934369c4333e9cf22b2c39cf717f760241d59 100644
--- a/tests/external_function/first_deriv_given_dll.mod
+++ b/tests/external_function/first_deriv_given_dll.mod
@@ -45,7 +45,7 @@ end;
 
 stoch_simul;
 
-L = load('benchmark_results.mat');
+L = load(['benchmark' filesep 'Output' filesep 'benchmark_results.mat']);
 if max(max(abs(L.oo_.dr.ghu - oo_.dr.ghu))) > 1e-12
   error('Failure in external function')
 end
diff --git a/tests/external_function/no_deriv_given.mod b/tests/external_function/no_deriv_given.mod
index c75cd10c153cb3a7328f83a8bd54ee4f85d03b56..44652a504c357409a14a323c9d215fbcd07b2f84 100644
--- a/tests/external_function/no_deriv_given.mod
+++ b/tests/external_function/no_deriv_given.mod
@@ -45,7 +45,7 @@ end;
 
 stoch_simul;
 
-L = load('benchmark_results.mat');
+L = load(['benchmark' filesep 'Output' filesep 'benchmark_results.mat']);
 if max(max(abs(L.oo_.dr.ghu - oo_.dr.ghu))) > 1e-9
   error('Failure in external function')
 end
diff --git a/tests/external_function/no_deriv_given_dll.mod b/tests/external_function/no_deriv_given_dll.mod
index 20741684721e44f63acff4f118462033fcb77631..5ad3bcc2eaa1b20f95e8cfa4075dfeb73f13e17a 100644
--- a/tests/external_function/no_deriv_given_dll.mod
+++ b/tests/external_function/no_deriv_given_dll.mod
@@ -45,7 +45,7 @@ end;
 
 stoch_simul;
 
-L = load('benchmark_results.mat');
+L = load(['benchmark' filesep 'Output' filesep 'benchmark_results.mat']);
 if max(max(abs(L.oo_.dr.ghu - oo_.dr.ghu))) > 1e-9
   error('Failure in external function')
 end
diff --git a/tests/gsa/ls2003.mod b/tests/gsa/ls2003.mod
index 3c1b3c9100d32b14f43016d97b653bf9e918017e..d4a56b4d5ebee864e0349dc9ae5343e35cbfbc02 100644
--- a/tests/gsa/ls2003.mod
+++ b/tests/gsa/ls2003.mod
@@ -152,7 +152,7 @@ estimation(datafile='data_ca1.m',first_obs=8,nobs=79,mh_nblocks=1,
 
 // run this to produce posterior samples of filtered, smoothed and irf variables, if not yet done
 //estimation(datafile='data_ca1.m',first_obs=8,nobs=79,mh_nblocks=2,prefilter=1,mh_jscale=0.3,
-//          mh_replic=0, mode_file=ls2003_mode, mode_compute=0, load_mh_file, bayesian_irf,
+//          mh_replic=0, mode_file='ls2003/Output/ls2003_mode', mode_compute=0, load_mh_file, bayesian_irf,
 //		  filtered_vars, smoother, mh_drop=0.6);
 
 disp(' ');
@@ -163,7 +163,7 @@ disp(' ');
 disp('Press ENTER to continue'); pause(5);
 
 dynare_sensitivity(nodisplay, pprior=0,Nsam=512,neighborhood_width=0.2,
-mode_file=ls2003_mode,  // specifies the mode file where the mode and Hessian are stored
+mode_file='ls2003/Output/ls2003_mode',  // specifies the mode file where the mode and Hessian are stored
 datafile='data_ca1.m',first_obs=8,nobs=79,prefilter=1,
 rmse=1);
 
@@ -174,7 +174,7 @@ disp(' ');
 disp('Press ENTER to continue'); pause(5);
 
 dynare_sensitivity(nodisplay, pprior=0,Nsam=512,
-mode_file=ls2003_mode  // specifies the mode file where the mode and Hessian are stored
+mode_file='ls2003/Output/ls2003_mode'  // specifies the mode file where the mode and Hessian are stored
 );
 
 
@@ -182,7 +182,7 @@ disp(' ');
 disp('RMSE ANALYSIS FOR MULTIVARIATE SAMPLE AT THE POSTERIOR MODE');
 disp(' ');
 disp('Press ENTER to continue'); pause(5);
-dynare_sensitivity(nodisplay, mode_file=ls2003_mode,
+dynare_sensitivity(nodisplay, mode_file='ls2003/Output/ls2003_mode',
 datafile='data_ca1.m',first_obs=8,nobs=79,prefilter=1,
 pprior=0,
 stab=0,
@@ -200,7 +200,7 @@ disp('datafile=data_ca1.m,first_obs=8,nobs=79,prefilter=1,')
 disp('rmse=1, alpha2_rmse=0, alpha_rmse=0);')
 disp(' ');
 disp('Press ENTER to continue'); pause(5);
-//dynare_sensitivity(pprior=0,Nsam=2048,alpha2_stab=0.4,mode_file=ls2003_mode,
+//dynare_sensitivity(pprior=0,Nsam=2048,alpha2_stab=0.4,mode_file='ls2003/Output/ls2003_mode',
 //datafile='data_ca1.m',first_obs=8,nobs=79,prefilter=1,
 //rmse=1,
 //alpha2_rmse=0, // no correlation analysis
@@ -211,7 +211,7 @@ disp(' ');
 disp('RMSE ANALYSIS FOR POSTERIOR MCMC sample (ppost=1)');
 disp('Needs a call to dynare_estimation to load all MH environment');
 disp('Press ENTER to continue'); pause(5);
-//estimation(datafile='data_ca1.m',first_obs=8,nobs=79,mh_nblocks=2, mode_file=ls2003_mode, load_mh_file,
+//estimation(datafile='data_ca1.m',first_obs=8,nobs=79,mh_nblocks=2, mode_file='ls2003/Output/ls2003_mode', load_mh_file,
 //  prefilter=1,mh_jscale=0.5,mh_replic=0, mode_compute=0, mh_drop=0.6);
 
 dynare_sensitivity(nodisplay, stab=0, // no need for stability analysis since the posterior sample is surely OK
diff --git a/tests/histval_initval_file/sim_exo_lead_lag_initvalf.mod b/tests/histval_initval_file/sim_exo_lead_lag_initvalf.mod
index 43e129e3e4c34944c46f8437fbb623f45f23fb26..ec6f47bb26d031119aa145be043ef45460487ad2 100644
--- a/tests/histval_initval_file/sim_exo_lead_lag_initvalf.mod
+++ b/tests/histval_initval_file/sim_exo_lead_lag_initvalf.mod
@@ -38,7 +38,7 @@ if ~oo_.deterministic_simulation.status
    error('Perfect foresight simulation failed');
 end
 
-base_results=load('sim_exo_lead_lag_results.mat');
+base_results=load(['sim_exo_lead_lag' filesep 'Output' filesep 'sim_exo_lead_lag_results.mat']);
 if max(max(abs(base_results.oo_.endo_simul(1:5,:) - oo_.endo_simul(1:5,:)))) > 1e-8
     error('Simulation with leads and lags doesn''t match the one with auxiliary variables')
 end
@@ -63,7 +63,7 @@ if ~oo_.deterministic_simulation.status
    error('Perfect foresight simulation failed');
 end
 
-base_results=load('sim_exo_lead_lag_results.mat');
+base_results=load(['sim_exo_lead_lag' filesep 'Output' filesep 'sim_exo_lead_lag_results.mat']);
 if max(max(abs(base_results.oo_.endo_simul(1:5,:) - oo_.endo_simul(1:5,:)))) > 1e-8
     error('Simulation with leads and lags doesn''t match the one with auxiliary variables')
 end
@@ -84,7 +84,7 @@ if ~oo_.deterministic_simulation.status
    error('Perfect foresight simulation failed');
 end
 
-base_results=load('sim_exo_lead_lag_results.mat');
+base_results=load(['sim_exo_lead_lag' filesep 'Output' filesep 'sim_exo_lead_lag_results.mat']);
 if max(max(abs(base_results.oo_.endo_simul(1:5,:) - oo_.endo_simul(1:5,:)))) > 1e-8
     error('Simulation with leads and lags doesn''t match the one with auxiliary variables')
 end
@@ -105,7 +105,7 @@ if ~oo_.deterministic_simulation.status
    error('Perfect foresight simulation failed');
 end
 
-base_results=load('sim_exo_lead_lag_results.mat');
+base_results=load(['sim_exo_lead_lag' filesep 'Output' filesep 'sim_exo_lead_lag_results.mat']);
 if max(max(abs(base_results.oo_.endo_simul(1:5,:) - oo_.endo_simul(1:5,:)))) > 1e-8
     error('Simulation with leads and lags doesn''t match the one with auxiliary variables')
 end
@@ -126,7 +126,7 @@ if ~oo_.deterministic_simulation.status
    error('Perfect foresight simulation failed');
 end
 
-base_results=load('sim_exo_lead_lag_results.mat');
+base_results=load(['sim_exo_lead_lag' filesep 'Output' filesep 'sim_exo_lead_lag_results.mat']);
 if max(max(abs(base_results.oo_.endo_simul(1:5,:) - oo_.endo_simul(1:5,:)))) > 1e-8
     error('Simulation with leads and lags doesn''t match the one with auxiliary variables')
 end
diff --git a/tests/k_order_perturbation/fs2000k2_m.mod b/tests/k_order_perturbation/fs2000k2_m.mod
index b1dd6f80e29dc1e7b6fb15c8eae83b87f6d49f0c..02ca4545081bdb5519f4096c4c2beb1a23a371ab 100644
--- a/tests/k_order_perturbation/fs2000k2_m.mod
+++ b/tests/k_order_perturbation/fs2000k2_m.mod
@@ -66,11 +66,11 @@ steady;
 
 stoch_simul(order=2,k_order_solver,periods=1000);
 
-if ~exist('fs2000k2a_results.mat','file');
+if ~exist(['fs2000k2a' filesep 'Output' filesep 'fs2000k2a_results.mat'],'file');
    error('fs2000k2a must be run first');
 end;
 
-oo1 = load('fs2000k2a_results','oo_');
+oo1 = load(['fs2000k2a' filesep 'Output' filesep 'fs2000k2a_results'],'oo_');
 
 dr0 = oo1.oo_.dr;
 dr = oo_.dr;
diff --git a/tests/k_order_perturbation/fs2000k2_use_dll.mod b/tests/k_order_perturbation/fs2000k2_use_dll.mod
index 20284beca8155166714e2840103ecab8f45e47d9..9b5ea9dd9553646b66db78af28fade1738a0ae91 100644
--- a/tests/k_order_perturbation/fs2000k2_use_dll.mod
+++ b/tests/k_order_perturbation/fs2000k2_use_dll.mod
@@ -66,11 +66,11 @@ steady;
 
 stoch_simul(order=2,k_order_solver,periods=1000);
 
-if ~exist('fs2000k2a_results.mat','file');
+if ~exist(['fs2000k2a' filesep 'Output' filesep 'fs2000k2a_results.mat'],'file');
    error('fs2000k2a must be run first');
 end;
 
-oo1 = load('fs2000k2a_results','oo_');
+oo1 = load(['fs2000k2a' filesep 'Output' filesep 'fs2000k2a_results'],'oo_');
 
 dr0 = oo1.oo_.dr;
 dr = oo_.dr;
diff --git a/tests/k_order_perturbation/fs2000k3_m.mod b/tests/k_order_perturbation/fs2000k3_m.mod
index 0e2529763f5d9b0007faddd6ad81eea1d811908d..fa91efec8d601ae1338c7ac6f95e148c1ac0323d 100644
--- a/tests/k_order_perturbation/fs2000k3_m.mod
+++ b/tests/k_order_perturbation/fs2000k3_m.mod
@@ -66,11 +66,11 @@ steady;
 
 stoch_simul(order=3,periods=1000);
 
-if ~exist('fs2000k2a_results.mat','file');
+if ~exist(['fs2000k2a' filesep 'Output' filesep 'fs2000k2a_results.mat'],'file');
    error('fs2000k2a must be run first');
 end;
 
-oo1 = load('fs2000k2a_results','oo_');
+oo1 = load(['fs2000k2a' filesep 'Output' filesep 'fs2000k2a_results'],'oo_');
 
 dr0 = oo1.oo_.dr;
 dr = oo_.dr;
diff --git a/tests/k_order_perturbation/fs2000k3_use_dll.mod b/tests/k_order_perturbation/fs2000k3_use_dll.mod
index 88821218a4e7515033a85a637d68c5d011c21d2b..2028443b60337d372b399a22c3bc81ca12b07ff6 100644
--- a/tests/k_order_perturbation/fs2000k3_use_dll.mod
+++ b/tests/k_order_perturbation/fs2000k3_use_dll.mod
@@ -66,11 +66,11 @@ steady;
 
 stoch_simul(order=3,periods=1000);
 
-if ~exist('fs2000k2a_results.mat','file');
+if ~exist(['fs2000k2a' filesep 'Output' filesep 'fs2000k2a_results.mat'],'file');
    error('fs2000k2a must be run first');
 end;
 
-oo1 = load('fs2000k2a_results','oo_');
+oo1 = load(['fs2000k2a' filesep 'Output' filesep 'fs2000k2a_results'],'oo_');
 
 dr0 = oo1.oo_.dr;
 dr = oo_.dr;
diff --git a/tests/k_order_perturbation/fs2000k_1_m.mod b/tests/k_order_perturbation/fs2000k_1_m.mod
index 5cd18f42c8bef5b2cc82c96da20c352b73702652..f4bad22ce1300e718ead044c48d1bf4c806403e2 100644
--- a/tests/k_order_perturbation/fs2000k_1_m.mod
+++ b/tests/k_order_perturbation/fs2000k_1_m.mod
@@ -74,11 +74,11 @@ steady;
 
 stoch_simul(order=2,k_order_solver,irf=0);
 
-if ~exist('fs2000k2_m_results.mat','file');
+if ~exist(['fs2000k2_m' filesep 'Output' filesep 'fs2000k2_m_results.mat'],'file');
    error('fs2000k2_m must be run first');
 end;
 
-oo1 = load('fs2000k2_m_results','oo_');
+oo1 = load(['fs2000k2_m' filesep 'Output' filesep 'fs2000k2_m_results'],'oo_');
 
 dr0 = oo1.oo_.dr;
 dr = oo_.dr;
diff --git a/tests/k_order_perturbation/fs2000k_1_use_dll.mod b/tests/k_order_perturbation/fs2000k_1_use_dll.mod
index 4de96ae2549a870099afd65348186acb633eb3d9..f4eb0300810d3c83a13fe5c8a55ea5dc8add1e73 100644
--- a/tests/k_order_perturbation/fs2000k_1_use_dll.mod
+++ b/tests/k_order_perturbation/fs2000k_1_use_dll.mod
@@ -73,11 +73,11 @@ steady;
 
 stoch_simul(order=2,k_order_solver,irf=0);
 
-if ~exist('fs2000k2_use_dll_results.mat','file');
+if ~exist(['fs2000k2_use_dll' filesep 'Output' filesep 'fs2000k2_use_dll_results.mat'],'file');
    error('fs2000k2_use_dll must be run first');
 end;
 
-oo1 = load('fs2000k2_use_dll_results','oo_');
+oo1 = load(['fs2000k2_use_dll' filesep 'Output' filesep 'fs2000k2_use_dll_results'],'oo_');
 
 dr0 = oo1.oo_.dr;
 dr = oo_.dr;
diff --git a/tests/kalman/likelihood_from_dynare/fs2000_corr_ME.mod b/tests/kalman/likelihood_from_dynare/fs2000_corr_ME.mod
index 17756e640fb1d736c1ae39dfb3199115ed7d590b..25443b5c297e7746b327ee3511364201b48ca397 100644
--- a/tests/kalman/likelihood_from_dynare/fs2000_corr_ME.mod
+++ b/tests/kalman/likelihood_from_dynare/fs2000_corr_ME.mod
@@ -12,7 +12,7 @@ stderr gy_obs, 1;
 corr gp_obs, gy_obs,0;
 end;
 
-@#define mode_file_name="fs2000_corr_ME_mode"
+@#define mode_file_name="'fs2000_corr_ME/Output/fs2000_corr_ME_mode'"
 @#define data_file_name="fsdat_simul_corr_ME"
 
 @#include "fs2000_estimation_check.inc" 
\ No newline at end of file
diff --git a/tests/kalman/likelihood_from_dynare/fs2000_corr_ME_missing.mod b/tests/kalman/likelihood_from_dynare/fs2000_corr_ME_missing.mod
index 860d6242b061307203720301eb84a257e50575a6..7810b432fb250139f5a76f5176f6b4bd8af9d29a 100644
--- a/tests/kalman/likelihood_from_dynare/fs2000_corr_ME_missing.mod
+++ b/tests/kalman/likelihood_from_dynare/fs2000_corr_ME_missing.mod
@@ -12,7 +12,7 @@ stderr gy_obs, 1;
 corr gp_obs, gy_obs,0;
 end;
 
-@#define mode_file_name="fs2000_corr_ME_missing_mode"
+@#define mode_file_name="'fs2000_corr_ME_missing/Output/fs2000_corr_ME_missing_mode'"
 @#define data_file_name="fsdat_simul_corr_ME_missing"
 
 @#include "fs2000_estimation_check.inc" 
\ No newline at end of file
diff --git a/tests/kalman/likelihood_from_dynare/fs2000_uncorr_ME.mod b/tests/kalman/likelihood_from_dynare/fs2000_uncorr_ME.mod
index 7376f42bb3c9e84f89ec4db67a8e5f7cd2cf53da..95cd231ea4390565d5437497f222ed366f3c1f70 100644
--- a/tests/kalman/likelihood_from_dynare/fs2000_uncorr_ME.mod
+++ b/tests/kalman/likelihood_from_dynare/fs2000_uncorr_ME.mod
@@ -29,7 +29,7 @@ stderr gy_obs, 1;
 //corr gp_obs, gy_obs,0;
 end;
 
-@#define mode_file_name="fs2000_uncorr_ME_mode"
+@#define mode_file_name="'fs2000_uncorr_ME/Output/fs2000_uncorr_ME_mode'"
 @#define data_file_name="fsdat_simul_uncorr_ME"
 
 @#include "fs2000_estimation_check.inc" 
\ No newline at end of file
diff --git a/tests/kalman/likelihood_from_dynare/fs2000_uncorr_ME_missing.mod b/tests/kalman/likelihood_from_dynare/fs2000_uncorr_ME_missing.mod
index 77cac92692f133ee2a5501f9b713312efcdd328e..3dd1c54976f94760bee614ed330c12b6e0f7ef33 100644
--- a/tests/kalman/likelihood_from_dynare/fs2000_uncorr_ME_missing.mod
+++ b/tests/kalman/likelihood_from_dynare/fs2000_uncorr_ME_missing.mod
@@ -12,7 +12,7 @@ stderr gy_obs, 1;
 //corr gp_obs, gy_obs,0;
 end;
 
-@#define mode_file_name="fs2000_uncorr_ME_missing_mode"
+@#define mode_file_name="'fs2000_uncorr_ME_missing/Output/fs2000_uncorr_ME_missing_mode'"
 @#define data_file_name="fsdat_simul_uncorr_ME_missing"
 
 @#include "fs2000_estimation_check.inc" 
diff --git a/tests/kalman/likelihood_from_dynare/fs2000ns_corr_ME.mod b/tests/kalman/likelihood_from_dynare/fs2000ns_corr_ME.mod
index edeaa1743f89b86608bf45f68ddd04bfee36d49d..2f9de9afd8125aa304d40762d97f67d72605c55c 100644
--- a/tests/kalman/likelihood_from_dynare/fs2000ns_corr_ME.mod
+++ b/tests/kalman/likelihood_from_dynare/fs2000ns_corr_ME.mod
@@ -12,7 +12,7 @@ stderr Y_obs, 0.05;
 corr Y_obs, P_obs,0.5;
 end;
 
-@#define mode_file_name="fs2000ns_corr_ME_mode"
+@#define mode_file_name="'fs2000ns_corr_ME/Output/fs2000ns_corr_ME_mode'"
 @#define data_file_name="fs_ns_dat_simul_corr_ME"
 
 @#include "fs2000ns_estimation_check.inc" 
diff --git a/tests/kalman/likelihood_from_dynare/fs2000ns_corr_ME_missing.mod b/tests/kalman/likelihood_from_dynare/fs2000ns_corr_ME_missing.mod
index 41741474cd2d42d891b7ba21e9744cebdb004b89..da8317d5cee3152db8d89f0f05286dac1c4a5f30 100644
--- a/tests/kalman/likelihood_from_dynare/fs2000ns_corr_ME_missing.mod
+++ b/tests/kalman/likelihood_from_dynare/fs2000ns_corr_ME_missing.mod
@@ -12,7 +12,7 @@ stderr Y_obs, 0.05;
 corr Y_obs, P_obs,0.5;
 end;
 
-@#define mode_file_name="fs2000ns_corr_ME_missing_mode"
+@#define mode_file_name="'fs2000ns_corr_ME_missing/Output/fs2000ns_corr_ME_missing_mode'"
 @#define data_file_name="fs_ns_dat_simul_corr_ME_missing"
 
 @#include "fs2000ns_estimation_check.inc" 
diff --git a/tests/kalman/likelihood_from_dynare/fs2000ns_uncorr_ME.mod b/tests/kalman/likelihood_from_dynare/fs2000ns_uncorr_ME.mod
index 61072d20f578e338b7168443f92e53e52b33f74f..0e6ba9443ac40c6d401da8087f4c24b75a04ad89 100644
--- a/tests/kalman/likelihood_from_dynare/fs2000ns_uncorr_ME.mod
+++ b/tests/kalman/likelihood_from_dynare/fs2000ns_uncorr_ME.mod
@@ -36,7 +36,7 @@ stderr Y_obs, 0.05;
 //corr gp_obs, gy_obs,0;
 end;
 
-@#define mode_file_name="fs2000ns_uncorr_ME_mode"
+@#define mode_file_name="'fs2000ns_uncorr_ME/Output/fs2000ns_uncorr_ME_mode'"
 @#define data_file_name="fs_ns_dat_simul_uncorr_ME"
 
 @#include "fs2000ns_estimation_check.inc" 
diff --git a/tests/kalman/likelihood_from_dynare/fs2000ns_uncorr_ME_missing.mod b/tests/kalman/likelihood_from_dynare/fs2000ns_uncorr_ME_missing.mod
index 2d0550e5019106d62da601826d3aac474d46d454..fcf83f8aa13a1848c24034c78d23e5451d33bcf2 100644
--- a/tests/kalman/likelihood_from_dynare/fs2000ns_uncorr_ME_missing.mod
+++ b/tests/kalman/likelihood_from_dynare/fs2000ns_uncorr_ME_missing.mod
@@ -12,7 +12,7 @@ stderr Y_obs, 0.05;
 //corr gp_obs, gy_obs,0;
 end;
 
-@#define mode_file_name="fs2000ns_uncorr_ME_missing_mode"
+@#define mode_file_name="'fs2000ns_uncorr_ME_missing/Output/fs2000ns_uncorr_ME_missing_mode'"
 @#define data_file_name="fs_ns_dat_simul_uncorr_ME_missing"
 
 @#include "fs2000ns_estimation_check.inc" 
diff --git a/tests/kalman_filter_smoother/algo2.mod b/tests/kalman_filter_smoother/algo2.mod
index 89bca775048d72997cf536cdb2f41f5746082324..b18eeb42a1763247b3a0eabbe448e1e493be4a25 100644
--- a/tests/kalman_filter_smoother/algo2.mod
+++ b/tests/kalman_filter_smoother/algo2.mod
@@ -32,7 +32,7 @@ end;
 
 varobs dw dx dy z;
 
-estimation(datafile=data,first_obs=1000,nobs=200,mh_replic=0,mode_compute=0,mode_file=algo1_mode,kalman_algo=2,filtered_vars,smoothed_state_uncertainty);
+estimation(datafile=data,first_obs=1000,nobs=200,mh_replic=0,mode_compute=0,mode_file='algo1/Output/algo1_mode',kalman_algo=2,filtered_vars,smoothed_state_uncertainty);
 
 //checking smoother consistency
 X = oo_.SmoothedVariables;
@@ -55,7 +55,7 @@ if max(max(abs(dat(1000:1199,:)-S(:,[2:4 1])))) > 1e-10;
    error('Test fails');
 end;
 
-o1 = load('algo1_results');
+o1 = load(['algo1' filesep 'Output' filesep 'algo1_results.mat']);
 obj_endo={'SmoothedVariables'; 'FilteredVariables'; 'UpdatedVariables'};
 obj_exo = {'SmoothedShocks';}; 
 nobj_endo = size(obj_endo,1);
diff --git a/tests/kalman_filter_smoother/algo4.mod b/tests/kalman_filter_smoother/algo4.mod
index 1d07bc93c84f4c44986986ea1df06a783c7e2e83..7d26340ce74234762dab5dab5c4dd74246183f9d 100644
--- a/tests/kalman_filter_smoother/algo4.mod
+++ b/tests/kalman_filter_smoother/algo4.mod
@@ -35,7 +35,7 @@ end;
 
 varobs w x y;
 
-estimation(datafile=data,first_obs=1000,nobs=200,mh_replic=0,mode_compute=0,mode_file=algo3_mode,diffuse_filter,kalman_algo=4,filtered_vars,smoothed_state_uncertainty);
+estimation(datafile=data,first_obs=1000,nobs=200,mh_replic=0,mode_compute=0,mode_file='algo3/Output/algo3_mode',diffuse_filter,kalman_algo=4,filtered_vars,smoothed_state_uncertainty);
 
 //checking smoother consistency
 X = oo_.SmoothedVariables;
@@ -58,7 +58,7 @@ if max(max(abs(dat(1000:1199,:)-S(:,[7:9])))) > 1e-10;
    error('Test fails');
 end;
 
-o1 = load('algo3_results');
+o1 = load(['algo3' filesep 'Output' filesep 'algo3_results.mat']);
 obj_endo={'SmoothedVariables'; 'FilteredVariables'; 'UpdatedVariables'};
 obj_exo = {'SmoothedShocks';}; 
 nobj_endo = size(obj_endo,1);
diff --git a/tests/kalman_filter_smoother/algo4a.mod b/tests/kalman_filter_smoother/algo4a.mod
index 9ca4675018deee7585162cc22ec68b447220bec6..28c8b6511483f58355c4e00d28da4cf95535507e 100644
--- a/tests/kalman_filter_smoother/algo4a.mod
+++ b/tests/kalman_filter_smoother/algo4a.mod
@@ -34,7 +34,7 @@ end;
 varobs dw dx y z;
        
 estimation(datafile=data,first_obs=1000,nobs=200,mh_replic=0,diffuse_filter);
-//estimation(datafile=data,first_obs=1000,nobs=200,mh_replic=0,mode_compute=0,mode_file=algo3_mode,diffuse_filter);
+//estimation(datafile=data,first_obs=1000,nobs=200,mh_replic=0,mode_compute=0,mode_file='algo3/Output/algo3_mode',diffuse_filter);
 
 //checking smoother consistency
 X = oo_.SmoothedVariables;
diff --git a/tests/kalman_filter_smoother/algo4b.mod b/tests/kalman_filter_smoother/algo4b.mod
index 37d743bbb733bea9d2abaa3914cf04350d8183b8..0e6c6da92597e3cf6d001ac48e2269cd652400be 100644
--- a/tests/kalman_filter_smoother/algo4b.mod
+++ b/tests/kalman_filter_smoother/algo4b.mod
@@ -34,7 +34,7 @@ end;
 varobs dw dx y z;
        
 estimation(datafile=data,first_obs=1000,nobs=200,mh_replic=0,diffuse_filter,smoothed_state_uncertainty);
-//estimation(datafile=data,first_obs=1000,nobs=200,mh_replic=0,mode_compute=0,mode_file=algo3_mode,diffuse_filter);
+//estimation(datafile=data,first_obs=1000,nobs=200,mh_replic=0,mode_compute=0,mode_file='algo3/Output/algo3_mode',diffuse_filter);
 
 //checking smoother consistency
 X = oo_.SmoothedVariables;
diff --git a/tests/kalman_filter_smoother/algoH2.mod b/tests/kalman_filter_smoother/algoH2.mod
index b6d5f2b4b952c2c190a5a230fbe778969449cebb..39f750995b5af24388a31b36db9749b1a98bdfaa 100644
--- a/tests/kalman_filter_smoother/algoH2.mod
+++ b/tests/kalman_filter_smoother/algoH2.mod
@@ -35,7 +35,7 @@ end;
 varobs dw dx dy z;
        
 //estimation(datafile=data,first_obs=1000,nobs=200,mh_replic=0,kalman_algo=2);
-estimation(datafile=data,first_obs=1000,nobs=200,mh_replic=0,mode_compute=0,mode_file=algoH1_mode,kalman_algo=2,filtered_vars,smoothed_state_uncertainty);
+estimation(datafile=data,first_obs=1000,nobs=200,mh_replic=0,mode_compute=0,mode_file='algoH1/Output/algoH1_mode',kalman_algo=2,filtered_vars,smoothed_state_uncertainty);
 
 //checking smoother consistency
 X = oo_.SmoothedVariables;
@@ -60,7 +60,7 @@ if max(max(abs(dat(1000:1199,:)-S(:,[2:4 1])-ME))) > 1e-10;
    error('Test fails');
 end;    
 
-o1 = load('algoH1_results');
+o1 = load(['algoH1' filesep 'Output' filesep 'algoH1_results.mat']);
 obj_endo={'SmoothedVariables'; 'FilteredVariables'; 'UpdatedVariables'};
 obj_exo = {'SmoothedShocks';}; 
 nobj_endo = size(obj_endo,1);
diff --git a/tests/lmmcp/sw_newton.mod b/tests/lmmcp/sw_newton.mod
index f40297e0f7b4162d6260ba3b4a9f67a4ff701c11..bab473d026ec197eda3ed67223c2a51d379b78ba 100644
--- a/tests/lmmcp/sw_newton.mod
+++ b/tests/lmmcp/sw_newton.mod
@@ -71,7 +71,7 @@ simul(periods=1000);
 
 newton_solution_is_wrong = abs(evaluate_max_dynamic_residual(str2func('sw_newton.dynamic'), oo_.endo_simul, oo_.exo_simul, M_.params, oo_.steady_state, 1000, size(oo_.endo_simul, 1), 1, M_.lead_lag_incidence))>options_.dynatol.f;
 
-lmmcp = load('sw_lmmcp_results');
+lmmcp = load(['sw_lmmcp' filesep 'Output' filesep 'sw_lmmcp_results']);
 
 lmmcp_solution_is_wrong = abs(evaluate_max_dynamic_residual(str2func('sw_newton.dynamic'), lmmcp.oo_.endo_simul, lmmcp.oo_.exo_simul, M_.params, oo_.steady_state, 1000, size(oo_.endo_simul, 1), 1, M_.lead_lag_incidence))>options_.dynatol.f;
 
diff --git a/tests/loglinear/example4_loglinear_lagged_exogenous_a.mod b/tests/loglinear/example4_loglinear_lagged_exogenous_a.mod
index cf93edac98cdc410e251c3e1c5eaaefe3abe6f65..5d843aabbee99514fa80be68b4e699edb85c330e 100644
--- a/tests/loglinear/example4_loglinear_lagged_exogenous_a.mod
+++ b/tests/loglinear/example4_loglinear_lagged_exogenous_a.mod
@@ -69,7 +69,7 @@ end;
 
 stoch_simul(loglinear,order=1);
 
-D = load('example4_loglinear_lagged_exogenous_results');
+D = load(['example4_loglinear_lagged_exogenous' filesep 'Output' filesep 'example4_loglinear_lagged_exogenous_results']);
 
 test1 = D.oo_.dr.ghx - oo_.dr.ghx;
 if norm(test1) > 1e-16;
diff --git a/tests/occbin/model_borrcon/borrcon_0_std_shocks.mod b/tests/occbin/model_borrcon/borrcon_0_std_shocks.mod
index 2943458db076d90bef5684c85633f592408150b6..c43a0a2169d925a9c5dc1eb08b5fee5bc8d01f93 100644
--- a/tests/occbin/model_borrcon/borrcon_0_std_shocks.mod
+++ b/tests/occbin/model_borrcon/borrcon_0_std_shocks.mod
@@ -53,7 +53,7 @@ end;
 
 @#include "borrcon_common.inc"
 
-orig_results=load('borrcon_results.mat');
+orig_results=load(['borrcon' filesep 'Output' filesep 'borrcon_results.mat']);
 if max(max(abs(oo_.occbin.piecewise-orig_results.oo_.occbin.piecewise)))>1e-10
     error('Results do not match')
 end
diff --git a/tests/occbin/model_irrcap_twoconstraints/dynrbc_0_std_shocks.mod b/tests/occbin/model_irrcap_twoconstraints/dynrbc_0_std_shocks.mod
index 1c0579d5adb4453a8ec66fd56408b209ccd9da6e..f7c09446dbdad09b5c4c80b1b114e759576bf121 100644
--- a/tests/occbin/model_irrcap_twoconstraints/dynrbc_0_std_shocks.mod
+++ b/tests/occbin/model_irrcap_twoconstraints/dynrbc_0_std_shocks.mod
@@ -59,7 +59,7 @@ end;
 
 @#include "dynrbc_common.inc"
 
-orig_results=load('dynrbc_results.mat');
+orig_results=load(['dynrbc' filesep 'Output' filesep 'dynrbc_results.mat']);
 if max(max(abs(oo_.occbin.piecewise-orig_results.oo_.occbin.piecewise)))>1e-10
     error('Results do not match')
 end
diff --git a/tests/optimal_policy/neo_growth_ramsey.mod b/tests/optimal_policy/neo_growth_ramsey.mod
index 2c8ea07dc9bfb024fa19dbbf6604f8c8783617de..8185ca2f4428fe9183bb5a812fd49a95fb2596ce 100644
--- a/tests/optimal_policy/neo_growth_ramsey.mod
+++ b/tests/optimal_policy/neo_growth_ramsey.mod
@@ -33,13 +33,13 @@ stoch_simul(order=2, irf=0);
 
 planner_objective_value = evaluate_planner_objective(M_, options_, oo_);
 
-if ~exist('neo_growth_results.mat','file');
+if ~exist(['neo_growth' filesep 'Output' filesep 'neo_growth_results.mat'],'file');
    error('neo_growth must be run first');
 end;
 
-oo1 = load('neo_growth_results','oo_');
-M1 = load('neo_growth_results','M_');
-options1 = load('neo_growth_results','options_');
+oo1 = load(['neo_growth' filesep 'Output' filesep 'neo_growth_results'],'oo_');
+M1 = load(['neo_growth' filesep 'Output' filesep 'neo_growth_results'],'M_');
+options1 = load(['neo_growth' filesep 'Output' filesep 'neo_growth_results'],'options_');
 unc_W_hand = oo1.oo_.mean(strmatch('W',M1.M_.endo_names,'exact'));
 
 initial_condition_states = repmat(oo1.oo_.dr.ys,1,M1.M_.maximum_lag);
diff --git a/tests/optimal_policy/neo_growth_ramsey_foresight.mod b/tests/optimal_policy/neo_growth_ramsey_foresight.mod
index 57c34056b3a6ef948376bda130fe4612079b92c2..b4175f58f4ce519426ba79a3555f2483fcf6e57f 100644
--- a/tests/optimal_policy/neo_growth_ramsey_foresight.mod
+++ b/tests/optimal_policy/neo_growth_ramsey_foresight.mod
@@ -39,9 +39,9 @@ if ~exist('neo_growth_foresight_results.mat','file');
    error('neo_growth_foresight must be run first');
 end;
 
-oo1 = load('neo_growth_foresight_results','oo_');
-M1 = load('neo_growth_foresight_results','M_');
-options1 = load('neo_growth_foresight_results','options_');
+oo1 = load(['neo_growth_foresight' filesep 'Output' filesep 'neo_growth_foresight_results'],'oo_');
+M1 = load(['neo_growth_foresight' filesep 'Output' filesep 'neo_growth_foresight_results'],'M_');
+options1 = load(['neo_growth_foresight' filesep 'Output' filesep 'neo_growth_foresight_results'],'options_');
 cond_W_hand = oo1.oo_.endo_simul(strmatch('W',M1.M_.endo_names,'exact'),2);
 unc_W_hand = oo1.oo_.endo_simul(strmatch('W',M1.M_.endo_names,'exact'),end);
 
diff --git a/tests/optimal_policy/neo_growth_ramsey_k_order.mod b/tests/optimal_policy/neo_growth_ramsey_k_order.mod
index 658ed715178c51794b13ac044dfc7fe3ff3a8732..02a82d48b70275d72094bf615bef829d368b4cae 100644
--- a/tests/optimal_policy/neo_growth_ramsey_k_order.mod
+++ b/tests/optimal_policy/neo_growth_ramsey_k_order.mod
@@ -38,13 +38,13 @@ evaluate_planner_objective;
 if condWelfare~=oo_.planner_objective_value(1)
     error('Values do not match');
 end
-if ~exist('neo_growth_k_order_results.mat','file');
+if ~exist(['neo_growth_k_order' filesep 'Output' filesep 'neo_growth_k_order_results.mat'],'file');
    error('neo_growth_k_order must be run first');
 end;
 
-oo = load('neo_growth_k_order_results','oo_');
-M = load('neo_growth_k_order_results','M_');
-options = load('neo_growth_k_order_results','options_');
+oo = load(['neo_growth_k_order' filesep 'Output' filesep 'neo_growth_k_order_results'],'oo_');
+M = load(['neo_growth_k_order' filesep 'Output' filesep 'neo_growth_k_order_results'],'M_');
+options = load(['neo_growth_k_order' filesep 'Output' filesep 'neo_growth_k_order_results'],'options_');
 
 ind_U = strmatch('U', M.M_.endo_names,'exact');
 ind_W = strmatch('W', M.M_.endo_names,'exact');
diff --git a/tests/optimal_policy/nk_ramsey_expectation_a.mod b/tests/optimal_policy/nk_ramsey_expectation_a.mod
index fc79789371dc0bd7ac076fb793c22422b8a156eb..4a0f85aaf2a56fa00e3bd263abca7e3a080c7979 100644
--- a/tests/optimal_policy/nk_ramsey_expectation_a.mod
+++ b/tests/optimal_policy/nk_ramsey_expectation_a.mod
@@ -93,7 +93,7 @@ ramsey_model(planner_discount=0.99);
 stoch_simul(order=1,irf=0);
 evaluate_planner_objective;
 
-o1=load('nk_ramsey_expectation_results');
+o1=load(['nk_ramsey_expectation' filesep 'Output' filesep 'nk_ramsey_expectation_results']);
 if (norm(o1.oo_.dr.ghx-oo_.dr.ghx,inf) > 1e-12)
    error('ghx doesn''t match')
 end
diff --git a/tests/optimizers/fs2000_102.mod b/tests/optimizers/fs2000_102.mod
index 40646a9c01c7736b36ecf259ce8cea1526ab1f5c..f23ae2d774c8fb4256105ce343921e0c7066bbd9 100644
--- a/tests/optimizers/fs2000_102.mod
+++ b/tests/optimizers/fs2000_102.mod
@@ -1,5 +1,5 @@
 @#include "fs2000.common.inc"
 
 if ~isoctave() && exist('simulannealbnd','file')
-   estimation(mode_compute=102,mode_file='../estimation/fs2000_mode',order=1, datafile='../fs2000/fsdat_simul', nobs=192, mh_replic=0, mh_nblocks=2, mh_jscale=0.8);
+   estimation(mode_compute=102,mode_file='../estimation/fs2000/Output/fs2000_mode',order=1, datafile='../fs2000/fsdat_simul', nobs=192, mh_replic=0, mh_nblocks=2, mh_jscale=0.8);
 end
diff --git a/tests/optimizers/fs2000_6.mod b/tests/optimizers/fs2000_6.mod
index 21738c869306b3e319c65adcde82eeb524dd6b88..000fa1932c2e113a479467cf71e8492c78782075 100644
--- a/tests/optimizers/fs2000_6.mod
+++ b/tests/optimizers/fs2000_6.mod
@@ -3,5 +3,5 @@
 estimation(mode_compute=6,order=1, datafile='../fs2000/fsdat_simul', nobs=192, mh_replic=0, optim=('nclimb-mh', 10, 'ncov-mh', 1000, 'nscale-mh', 5000));
 
 // test the mode file generated with mode_compute=6
-estimation(order=1,datafile='../fs2000/fsdat_simul',nobs=192,loglinear,mode_compute=0,mode_file=fs2000_6_mode,mh_replic=10,
-        posterior_sampler_options=('scale_file','fs2000_6_optimal_mh_scale_parameter'));
+estimation(order=1,datafile='../fs2000/fsdat_simul',nobs=192,loglinear,mode_compute=0,mode_file='fs2000_6/Output/fs2000_6_mode',mh_replic=10,
+        posterior_sampler_options=('scale_file','fs2000_6/Output/fs2000_6_optimal_mh_scale_parameter'));
diff --git a/tests/parallel/ls2003.mod b/tests/parallel/ls2003.mod
index 64db3899c6088f44eae9064fc73152f57f1ac5b3..cf3d8d0769a5e5ec449a33dc46bd202749af7782 100644
--- a/tests/parallel/ls2003.mod
+++ b/tests/parallel/ls2003.mod
@@ -66,7 +66,7 @@ end;
 
 
 estimation(datafile=data_ca1,first_obs=8,nobs=79,mh_replic=0,nodisplay);
-estimation(datafile=data_ca1,first_obs=8,nobs=79,mode_compute=0,nodisplay, mode_file=ls2003_mode, mh_nblocks=4, prefilter=1, mh_jscale=0.5, mh_replic=2000);
-estimation(datafile=data_ca1,first_obs=8,nobs=79,mode_compute=0,nodisplay, mode_file=ls2003_mode, mh_nblocks=4,prefilter=1,mh_jscale=0.5,mh_replic=2000,bayesian_irf,load_mh_file,smoother,forecast=12, filtered_vars, filter_step_ahead=[1 2 3 4]) y y_s R pie dq pie_s de A y_obs pie_obs R_obs;
+estimation(datafile=data_ca1,first_obs=8,nobs=79,mode_compute=0,nodisplay, mode_file='ls2003/Output/ls2003_mode', mh_nblocks=4, prefilter=1, mh_jscale=0.5, mh_replic=2000);
+estimation(datafile=data_ca1,first_obs=8,nobs=79,mode_compute=0,nodisplay, mode_file='ls2003/Output/ls2003_mode', mh_nblocks=4,prefilter=1,mh_jscale=0.5,mh_replic=2000,bayesian_irf,load_mh_file,smoother,forecast=12, filtered_vars, filter_step_ahead=[1 2 3 4]) y y_s R pie dq pie_s de A y_obs pie_obs R_obs;
 
 
diff --git a/tests/pruning/AS_pruned_state_space_red_shock.mod b/tests/pruning/AS_pruned_state_space_red_shock.mod
index dfbc3571c851d68071716b8b5a7705c84cbeb9c1..177688e0528b00d32f90bc8a0a763c8834910566 100644
--- a/tests/pruning/AS_pruned_state_space_red_shock.mod
+++ b/tests/pruning/AS_pruned_state_space_red_shock.mod
@@ -144,7 +144,7 @@ for iorder = 1:3
         error('Something wrong with pruned_state_space.m compared to Andreasen et al 2018 Toolbox v2 at order %d.',iorder);
     end
     if iorder==3
-        pruned_without_shock = load('AnSchorfheide_pruned_state_space_results.mat');
+        pruned_without_shock = load(['AnSchorfheide_pruned_state_space' filesep 'Output' filesep 'AnSchorfheide_pruned_state_space_results.mat']);
         pruned_without_shock = pruned_without_shock.oo_.pruned;
         norm_E_yx   = norm(pruned.E_y   - pruned_without_shock.E_y , Inf);
         fprintf('max(sum(abs(E[y;x]''))): %d\n',norm_E_yx);
diff --git a/tests/second_order/ds2.mod b/tests/second_order/ds2.mod
index 66fa7fdb4a29e341ecc75992711a30d25d35007e..45a92208e637111f5d07c00a89687f07752c7840 100644
--- a/tests/second_order/ds2.mod
+++ b/tests/second_order/ds2.mod
@@ -68,7 +68,7 @@ model_diagnostics;
 check;
 stoch_simul(order=2,irf=0);
 
-o1 = load('ds1_results','oo_');
+o1 = load(['ds1' filesep 'Output' filesep 'ds1_results'],'oo_');
 oo1 = o1.oo_.dr;
 oo2 = oo_.dr;
 if any(abs(oo1.ghxx-oo2.ghxx) > 1e-14);error('ds1 with missing variable doesn''t reproduce ds2');end;
diff --git a/tests/smoother2histval/fs2000_simul.mod b/tests/smoother2histval/fs2000_simul.mod
index a682c76c04bbcbb957740d652c13bf2b366a7eb4..9b1b81f1c1e9bf704e7f17ddee85f6c22c603d68 100644
--- a/tests/smoother2histval/fs2000_simul.mod
+++ b/tests/smoother2histval/fs2000_simul.mod
@@ -62,11 +62,11 @@ var e_a; stderr 0.014;
 var e_m; stderr 0.005;
 end;
 
-results_estimation=load('fs2000_smooth_results');
+results_estimation=load(['fs2000_smooth' filesep 'Output' filesep 'fs2000_smooth_results']);
 M_.params=results_estimation.M_.params;
 steady;
 
-OO = load('fs2000_smooth_results.mat');
+OO = load(['fs2000_smooth' filesep 'Output' filesep 'fs2000_smooth_results']);;
 M_.params = OO.M_.params;
 
 histval_file(filename = 'fs2000_histval.mat');