diff --git a/matlab/CutSample.m b/matlab/CutSample.m
index bfbfeeed92861b851c7508c317d6465d3f81c329..bb2e8feca9c40e09e1293bd98f228d2efee02d6b 100644
--- a/matlab/CutSample.m
+++ b/matlab/CutSample.m
@@ -31,8 +31,6 @@ function CutSample(M_, options_, estim_params_)
 % You should have received a copy of the GNU General Public License
 % along with Dynare.  If not, see <http://www.gnu.org/licenses/>.
 
-global M_ options_ estim_params_
-
 npar = estim_params_.np+estim_params_.nvn+estim_params_.ncx+estim_params_.ncn+estim_params_.nvx;
 
 DirectoryName = CheckPath('metropolis');
@@ -50,7 +48,7 @@ else
 end
 TotalNumberOfMhFiles = sum(record.MhDraws(:,2));
 TotalNumberOfMhDraws = sum(record.MhDraws(:,1));
-MAX_nruns = ceil(options_.MaxNumberOfBytes/(npar+2)/8)
+MAX_nruns = ceil(options_.MaxNumberOfBytes/(npar+2)/8);
 FirstDraw = max(1,floor(options_.mh_drop*TotalNumberOfMhDraws));
 FirstMhFile = ceil(FirstDraw/MAX_nruns);
 FirstLine = FirstDraw-(FirstMhFile-1)*MAX_nruns+1;
diff --git a/matlab/GetPosteriorParametersStatistics.m b/matlab/GetPosteriorParametersStatistics.m
index 7f6abec491de8d53664d82a682e475f47d906d70..a23363712a41a86b52d3005ea187210749591f98 100644
--- a/matlab/GetPosteriorParametersStatistics.m
+++ b/matlab/GetPosteriorParametersStatistics.m
@@ -32,8 +32,6 @@ function oo_ = GetPosteriorParametersStatistics(estim_params_, M_, options_, bay
 % You should have received a copy of the GNU General Public License
 % along with Dynare.  If not, see <http://www.gnu.org/licenses/>.
 
-global estim_params_ M_ options_ bayestopt_ oo_
-
 %if ~options_.mh_replic & options_.load_mh_file
 %   load([M_.fname '_results.mat'],'oo_'); 
 %end
@@ -53,7 +51,7 @@ OutputDirectoryName = CheckPath('Output');
 load([ DirectoryName '/'  M_.fname '_mh_history'])
 FirstMhFile = record.KeepedDraws.FirstMhFile;
 FirstLine = record.KeepedDraws.FirstLine;
-TotalNumberOfMhFiles = sum(record.MhDraws(:,2))
+TotalNumberOfMhFiles = sum(record.MhDraws(:,2));
 TotalNumberOfMhDraws = sum(record.MhDraws(:,1));
 FirstMhFile = record.KeepedDraws.FirstMhFile;
 NumberOfDraws = TotalNumberOfMhDraws-floor(options_.mh_drop*TotalNumberOfMhDraws);
diff --git a/matlab/PlotPosteriorDistributions.m b/matlab/PlotPosteriorDistributions.m
index 1d1cac5e59a4fb42d512d5929bffab4858fcd373..190aaccf5df29a2d83721780cc2f562b3c536bdc 100644
--- a/matlab/PlotPosteriorDistributions.m
+++ b/matlab/PlotPosteriorDistributions.m
@@ -33,8 +33,6 @@ function oo_ = PlotPosteriorDistributions(estim_params_, M_, options_, bayestopt
 % You should have received a copy of the GNU General Public License
 % along with Dynare.  If not, see <http://www.gnu.org/licenses/>.
 
-global estim_params_ M_ options_ bayestopt_ oo_
-
 OutputDirectoryName = CheckPath('Output');
 
 TeX   	= options_.TeX;
diff --git a/matlab/check_list_of_variables.m b/matlab/check_list_of_variables.m
index 7ed79ccd96e1ad839812fe09a817e39fcd66de4d..6705ced009a40799bd2185b2d443c40fbe6bb59a 100644
--- a/matlab/check_list_of_variables.m
+++ b/matlab/check_list_of_variables.m
@@ -33,7 +33,7 @@ function varlist = check_list_of_variables(options_, M_, varlist)
 
     if isempty(varlist)
         disp(' ')
-        disp(['You did not declared endogenous variables after the estimation command.'])
+        disp(['You did not declare endogenous variables after the estimation command.'])
         cas = [];
         if options_.bayesian_irf
             cas = 'Posterior IRFs';
diff --git a/matlab/csminwel.m b/matlab/csminwel.m
index 809d7314e4699add7fb4443456810503c8cf3f87..e3439d8402e0ba476692869f367fd623ae67ce1c 100644
--- a/matlab/csminwel.m
+++ b/matlab/csminwel.m
@@ -198,7 +198,6 @@ while ~done
                      end
                      wall3=badg3;
                      % g3
-                     badg3
                      save g3.mat g3 x3 f3 varargin;
                      %ARGLIST
                      %save g3 g3 x3 f3 P1 P2 P3 P4 P5 P6 P7 P8 P9 P10 P11 P12 P13;
@@ -219,17 +218,17 @@ while ~done
    end
    %how to pick gh and xh
    if f3 < f - crit & badg3==0
-      ih=3
+      ih=3;
       fh=f3;xh=x3;gh=g3;badgh=badg3;retcodeh=retcode3;
    elseif f2 < f - crit & badg2==0
-      ih=2
+      ih=2;
       fh=f2;xh=x2;gh=g2;badgh=badg2;retcodeh=retcode2;
    elseif f1 < f - crit & badg1==0
-      ih=1
+      ih=1;
       fh=f1;xh=x1;gh=g1;badgh=badg1;retcodeh=retcode1;
    else
       [fh,ih] = min([f1,f2,f3]);
-      disp(sprintf('ih = %d',ih))
+      %disp(sprintf('ih = %d',ih))
       %eval(['xh=x' num2str(ih) ';'])
       switch ih
          case 1
diff --git a/matlab/dynare_estimation.m b/matlab/dynare_estimation.m
index 80319c69486698ce2ec99c8f09f89692b9a0a41b..f2e076a718f263597d3b75460384f49b046cd672 100644
--- a/matlab/dynare_estimation.m
+++ b/matlab/dynare_estimation.m
@@ -276,7 +276,7 @@ else% if the steady state file is not provided.
    oo_.steady_state = dd.ys; clear('dd');
 end
 if all(abs(oo_.steady_state(bayestopt_.mfys))<1e-9)
-    disp('no constant')
+    disp('No constant.')
     options_.noconstant = 1;
 else
     options_.noconstant = 0;
@@ -924,7 +924,7 @@ if (any(bayestopt_.pshape  >0 ) & options_.mh_replic) | ...
       McMCDiagnostics(options_, estim_params_, M_);
   end
   %% Here i discard first half of the draws:
-  CutSample;
+  CutSample(M_, options_, estim_params_);
   %% Estimation of the marginal density from the Mh draws:
   if options_.mh_replic
       [marginal,oo_] = marginal_density(M_, options_, estim_params_, oo_);
@@ -934,7 +934,6 @@ if (any(bayestopt_.pshape  >0 ) & options_.mh_replic) | ...
   %% Results are saved (in case of an anormal exit from dynare or matlab)...
   %%save([M_.fname '_results.mat'],'oo_','M_');
   %%
-  oo_
   oo_ = PlotPosteriorDistributions(estim_params_, M_, options_, bayestopt_, oo_);
   metropolis_draw(1);
   if options_.bayesian_irf
@@ -978,7 +977,7 @@ if (~((any(bayestopt_.pshape > 0) & options_.mh_replic) | (any(bayestopt_.pshape
     eval(['oo_.SmoothedVariables.' deblank(M_.endo_names(dr.order_var(i),:)) ' = atT(i,:)'';']);
     eval(['oo_.FilteredVariables.' deblank(M_.endo_names(dr.order_var(i),:)) ' = squeeze(aK(1,i,:))'';']);
     eval(['oo_.UpdatedVariables.' deblank(M_.endo_names(dr.order_var(i),:)) ...
-          ' = updated variables(i,:)'';']);
+          ' = updated_variables(i,:)'';']);
   end
   [nbplt,nr,nc,lr,lc,nstar] = pltorg(M_.exo_nbr);
   if options_.TeX
diff --git a/matlab/metropolis_hastings_initialization.m b/matlab/metropolis_hastings_initialization.m
index 1af16a4b58c34fe4d630ebc2d4c337b367aae95c..c7779afaee47012f13ddbe23ade4356756a02ddc 100644
--- a/matlab/metropolis_hastings_initialization.m
+++ b/matlab/metropolis_hastings_initialization.m
@@ -63,12 +63,12 @@ if ~options_.load_mh_file & ~options_.mh_recover
     files = dir([ MhDirectoryName '/' ModelName '_mh*_blck*.mat']);
     if length(files)
         delete([ MhDirectoryName '/' ModelName '_mh*_blck*.mat']);
-        disp('MH: Old _mh files succesfully erased!')
+        disp('MH: Old _mh files successfully erased!')
     end
     file = dir([ MhDirectoryName '/metropolis.log']);
     if length(file)
         delete([ MhDirectoryName '/metropolis.log']);
-        disp('MH: Old metropolis.log file succesfully erased!')
+        disp('MH: Old metropolis.log file successfully erased!')
         disp('MH: Creation of a new metropolis.log file.')
     end
     fidlog = fopen([MhDirectoryName '/metropolis.log'],'w');
@@ -150,7 +150,7 @@ if ~options_.load_mh_file & ~options_.mh_recover
     file = dir([MhDirectoryName '/'  ModelName '_mh_history.mat']);
     if length(files)
         delete([ MhDirectoryName '/' ModelName '_mh_history.mat']);
-        disp('MH: Old mh_history file succesfully erased!')
+        disp('MH: Old mh_history file successfully erased!')
     end
     AnticipatedNumberOfFiles = ceil(nruns(1)/MAX_nruns);
     AnticipatedNumberOfLinesInTheLastFile = nruns(1) - (AnticipatedNumberOfFiles-1)*MAX_nruns;