diff --git a/doc/dynare.texi b/doc/dynare.texi
index 8b11ce69adcd4409d4f771856122df1c7ca085f5..b06d56a92ece6ae549ca63812ee353ba5096b5af 100644
--- a/doc/dynare.texi
+++ b/doc/dynare.texi
@@ -9382,7 +9382,7 @@ parameters were correctly updated. The long names can be used to add parameter d
 following @LaTeX{} packages: @code{longtable}
 @end deffn
 
-@deffn {MATLAB/Octave command} collect_LaTeX_Files(M_,options_) ;
+@deffn {MATLAB/Octave command} collect_LaTeX_Files(M_) ;
 
 Writes a @LaTeX{} file named @code{<<M_.fname>>_TeX_binder.tex} that collects all @TeX{} output generated by Dynare 
 into a file. This file can be compiled using pdflatex and automatically tries to load all required packages. 
diff --git a/matlab/collect_LaTeX_Files.m b/matlab/collect_LaTeX_Files.m
index 65892af666b0adc2993f0c870f77f93a7b478201..d6cb76d5652826354a531b42ac7d78b4f9ceebf8 100644
--- a/matlab/collect_LaTeX_Files.m
+++ b/matlab/collect_LaTeX_Files.m
@@ -1,4 +1,4 @@
-function collect_LaTeX_Files(M_,options_)
+function collect_LaTeX_Files(M_)
 % function collect_LaTeX_Files(M_);
 % Creates TeX-File embedding all eps-loaders created for current mod-file
 % 
@@ -39,12 +39,6 @@ fprintf(fid,'%s \n','\usepackage{breqn}');
 fprintf(fid,'%s \n','\usepackage{float}');
 fprintf(fid,'%s \n','\begin{document}');
 
-if ~isfield(M_,'dname')
-    dname = options_.dirname;
-else
-    dname = M_.dname;
-end
-
 %% Root directory
 TeX_Files=dir([M_.fname,'*.TeX']);
 for ii=1:length(TeX_Files)
@@ -58,20 +52,20 @@ for ii=1:length(TeX_Files)
 end
 
 %% Output directory
-TeX_Files=dir([dname filesep 'Output' filesep  M_.fname '*.TeX']);
+TeX_Files=dir([M_.dname filesep 'Output' filesep  M_.fname '*.TeX']);
 for ii=1:length(TeX_Files)
     [pathstr,f_name,ext] = fileparts(TeX_Files(ii).name);
     if ~strcmp(TeX_Files(ii).name,f_name_binder)
-        fprintf(fid,'%s \n',['\include{', dname '/Output' '/',f_name,'}']);    
+        fprintf(fid,'%s \n',['\include{', M_.dname '/Output' '/',f_name,'}']);    
     end
 end
 
 %5 graphs directory
-TeX_Files=dir([dname filesep 'graphs' filesep  M_.fname '*.TeX']);
+TeX_Files=dir([M_.dname filesep 'graphs' filesep  M_.fname '*.TeX']);
 for ii=1:length(TeX_Files)
     [pathstr,f_name,ext] = fileparts(TeX_Files(ii).name);
     if ~strcmp(TeX_Files(ii).name,f_name_binder)
-        fprintf(fid,'%s \n',['\include{', dname '/graphs' '/',f_name,'}']);    
+        fprintf(fid,'%s \n',['\include{', M_.dname '/graphs' '/',f_name,'}']);    
     end
 end
 
diff --git a/matlab/dynare_identification.m b/matlab/dynare_identification.m
index 65f24154f091ba2567c821c22e32d8c1cf9b6e0a..2da320f4cba90e55ab71aac07ae136ffb8df55d8 100644
--- a/matlab/dynare_identification.m
+++ b/matlab/dynare_identification.m
@@ -45,9 +45,6 @@ else
 end
 
 fname_ = M_.fname;
-if ~isfield(M_,'dname'),
-    M_.dname = M_.fname;
-end
 options_ident = set_default_option(options_ident,'gsa_sample_file',0);
 options_ident = set_default_option(options_ident,'parameter_set','prior_mean');
 options_ident = set_default_option(options_ident,'load_ident_files',0);
diff --git a/matlab/dynare_sensitivity.m b/matlab/dynare_sensitivity.m
index 0a4aa0035cd65a395d41e258dadace2bb4c58c2e..1755b842828fc163fa47c2cbac71a1b96cc41df7 100644
--- a/matlab/dynare_sensitivity.m
+++ b/matlab/dynare_sensitivity.m
@@ -28,9 +28,6 @@ if options_.dsge_var
 end
 
 fname_ = M_.fname;
-if ~isfield(M_,'dname'),
-    M_.dname = M_.fname;
-end
 lgy_ = M_.endo_names;
 x0=[];
 
diff --git a/matlab/forecast_graphs.m b/matlab/forecast_graphs.m
index 33c538c8e033db6be152f4517b0a23490d2767a7..8a40a3ba91a151e6cce0081e2651e7b61ba3c94c 100644
--- a/matlab/forecast_graphs.m
+++ b/matlab/forecast_graphs.m
@@ -29,11 +29,8 @@ nc = 4;
 nr = 3;
 endo_names = M_.endo_names;
 fname = M_.fname;
-if ~isfield(M_,'dname')
-    dname = options_.dirname;
-else
-    dname = M_.dname;
-end
+dname = M_.dname;
+
 yf = oo_.forecast.Mean;
 hpdinf = oo_.forecast.HPDinf;
 hpdsup = oo_.forecast.HPDsup;
diff --git a/matlab/global_initialization.m b/matlab/global_initialization.m
index b1f304973601ec83330dd0bc5198968c6e6fd24e..f8e622a84a4353292fe2cd944384bd4b16f89b4d 100644
--- a/matlab/global_initialization.m
+++ b/matlab/global_initialization.m
@@ -34,6 +34,7 @@ estim_params_ = [];
 bayestopt_ = [];
 options_.datafile = '';
 options_.dirname = M_.fname;
+M_.dname = M_.fname;
 options_.dataset = [];
 options_.verbosity = 1;
 options_.terminal_condition = 0;
diff --git a/tests/TeX/fs2000_corr_ME.mod b/tests/TeX/fs2000_corr_ME.mod
index e53cc212038305644253408da4f38780f93ef239..f8bbe3c4ad422d4fe37edef74a2de4d361adec43 100644
--- a/tests/TeX/fs2000_corr_ME.mod
+++ b/tests/TeX/fs2000_corr_ME.mod
@@ -162,7 +162,7 @@ end;
 estimation(mode_compute=9,order=1,datafile='../fs2000/fsdat_simul',mode_check,smoother,filter_decomposition,mh_replic=2002, mh_nblocks=2, mh_jscale=0.8,forecast = 8,bayesian_irf,filtered_vars,filter_step_ahead=[1,3],irf=20,moments_varendo) m P c e W R k d y;
 shock_decomposition y W R;
 
-collect_LaTeX_Files(M_,options_);
+collect_LaTeX_Files(M_);
 
 //identification(advanced=1,max_dim_cova_group=3,prior_mc=250);
 if system(['pdflatex -halt-on-error ' M_.fname '_TeX_binder.TeX'])