From 88e170128914c701ef652bf62922f3772b45bda9 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Adjemian=20=28Charybdis=29?=
 <stephane.adjemian@univ-lemans.fr>
Date: Tue, 16 May 2017 12:42:01 +0200
Subject: [PATCH] Removed useless commas and semicolons.

---
 matlab/AHessian.m                             |   4 +-
 matlab/AIM/SPAimerr.m                         |   2 +-
 matlab/AIM/SPAmalg.m                          |   6 +-
 matlab/AIM/SPReduced_form.m                   |   2 +-
 matlab/AIM_first_order_solver.m               |   2 +-
 matlab/GetPosteriorParametersStatistics.m     |   4 +-
 matlab/PlotPosteriorDistributions.m           |   2 +-
 matlab/PosteriorIRF.m                         |  18 +-
 matlab/PosteriorIRF_core1.m                   |  18 +-
 matlab/PosteriorIRF_core2.m                   |  12 +-
 matlab/ReshapeMatFiles.m                      |   6 +-
 matlab/UnivariateSpectralDensity.m            |   2 +-
 matlab/WriteShockDecomp2Excel.m               |   8 +-
 matlab/annualized_shock_decomposition.m       |  38 +-
 matlab/basic_plan.m                           |   2 +-
 matlab/check_posterior_sampler_options.m      |  34 +-
 matlab/chol_SE.m                              |   8 +-
 .../convergence_diagnostics/McMCDiagnostics.m |  12 +-
 .../McMCDiagnostics_core.m                    |  14 +-
 .../geweke_chi2_test.m                        |   4 +-
 .../convergence_diagnostics/geweke_moments.m  |  10 +-
 matlab/convergence_diagnostics/mcmc_ifac.m    |   2 +-
 .../convergence_diagnostics/raftery_lewis.m   |  26 +-
 matlab/convertAimCodeToInfo.m                 |   2 +-
 matlab/convert_oo_.m                          |   2 +-
 matlab/cosn.m                                 |   6 +-
 matlab/csolve.m                               |   4 +-
 matlab/discretionary_policy_engine.m          |  14 +-
 matlab/disp_dr.m                              |   2 +-
 matlab/disp_identification.m                  |  46 +-
 matlab/disp_th_moments.m                      |   4 +-
 matlab/display_problematic_vars_Jacobian.m    |   2 +-
 .../inverse_gamma_specification.m             |   4 +-
 .../distributions/multivariate_normal_pdf.m   |   2 +-
 .../distributions/multivariate_student_pdf.m  |   2 +-
 matlab/dr_block.m                             |  90 +--
 matlab/draw_prior_density.m                   |   2 +-
 matlab/dsge_likelihood.m                      |  83 ++-
 .../dsge_simulated_theoretical_correlation.m  |   2 +-
 ...lated_theoretical_variance_decomposition.m |   2 +-
 matlab/dsge_var_likelihood.m                  |  10 +-
 matlab/dyn_autocorr.m                         |   2 +-
 matlab/dyn_first_order_solver.m               |  11 +-
 matlab/dyn_ramsey_static.m                    |   2 +-
 matlab/dyn_waitbar.m                          |  25 +-
 matlab/dyn_waitbar_close.m                    |   6 +-
 matlab/dynare.m                               |   6 +-
 matlab/dynare_estimation.m                    |   6 +-
 matlab/dynare_estimation_1.m                  |  29 +-
 matlab/dynare_estimation_init.m               |  16 +-
 matlab/dynare_graph.m                         |   2 +-
 matlab/dynare_identification.m                | 149 +++--
 matlab/dynare_resolve.m                       |   2 +-
 matlab/dynare_sensitivity.m                   | 142 +++--
 matlab/dynare_solve.m                         |   4 +-
 matlab/dynare_solve_block_or_bytecode.m       |   2 +-
 matlab/dynare_squeeze.m                       |   2 +-
 matlab/endogenous_prior_restrictions.m        |  65 +-
 matlab/ep/extended_path_initialization.m      |   2 +-
 matlab/ep/extended_path_shocks.m              |   2 +-
 matlab/evaluate_steady_state.m                |  50 +-
 matlab/evaluate_steady_state_file.m           |   2 +-
 matlab/fjaco.m                                |   2 +-
 matlab/flip_plan.m                            |   4 +-
 matlab/forecast_graphs.m                      |   4 +-
 matlab/formdata.m                             |  22 +-
 matlab/gensylv/gensylv.m                      |   4 +-
 matlab/gensylv/sylvester3.m                   |  18 +-
 matlab/gensylv/sylvester3a.m                  |   2 +-
 matlab/gensylv_fp.m                           |   8 +-
 matlab/getH.m                                 | 173 +++---
 matlab/getJJ.m                                |  26 +-
 matlab/get_Hessian.m                          |   6 +-
 matlab/get_new_or_existing_ei_index.m         |   2 +-
 matlab/graph_decomp.m                         |  12 +-
 matlab/graph_decomp_detail.m                  |  14 +-
 matlab/gsa/Morris_Measure_Groups.m            |   8 +-
 matlab/gsa/cumplot.m                          |   4 +-
 matlab/gsa/filt_mc_.m                         | 124 ++--
 matlab/gsa/gsa_plotmatrix.m                   |  18 +-
 matlab/gsa/gsa_skewness.m                     |   2 +-
 matlab/gsa/gsa_speed.m                        |   4 +-
 matlab/gsa/log_trans_.m                       |  12 +-
 matlab/gsa/map_calibration.m                  | 104 ++--
 matlab/gsa/map_ident_.m                       | 105 ++--
 matlab/gsa/mc_moments.m                       |   4 +-
 matlab/gsa/mcf_analysis.m                     |   6 +-
 matlab/gsa/myboxplot.m                        |   4 +-
 matlab/gsa/myprctilecol.m                     |   6 +-
 matlab/gsa/pick.m                             |   6 +-
 matlab/gsa/redform_map.m                      | 120 ++--
 matlab/gsa/redform_screen.m                   |  30 +-
 matlab/gsa/scatter_analysis.m                 |   4 +-
 matlab/gsa/scatter_mcf.m                      |  26 +-
 matlab/gsa/scatter_plots.m                    |  20 +-
 matlab/gsa/smirnov.m                          |   4 +-
 matlab/gsa/stab_map_.m                        | 120 ++--
 matlab/gsa/stab_map_1.m                       |  24 +-
 matlab/gsa/stab_map_2.m                       |  32 +-
 matlab/gsa/stand_.m                           |   6 +-
 matlab/gsa/tcrit.m                            |  12 +-
 matlab/gsa/teff.m                             |   6 +-
 matlab/gsa/th_moments.m                       |   6 +-
 matlab/gsa/trank.m                            |   4 +-
 matlab/ident_bruteforce.m                     |  12 +-
 matlab/identification_analysis.m              |  53 +-
 matlab/identification_checks.m                |  32 +-
 matlab/initial_condition_decomposition.m      |   2 +-
 matlab/k_order_pert.m                         |   8 +-
 matlab/kalman/likelihood/computeDLIK.m        |  26 +-
 matlab/kalman/likelihood/kalman_filter.m      |  34 +-
 matlab/kalman/likelihood/kalman_filter_fast.m |  18 +-
 matlab/kalman/likelihood/kalman_filter_ss.m   |  20 +-
 .../missing_observations_kalman_filter.m      |   2 +-
 .../likelihood/univariate_computeDLIK.m       |  40 +-
 .../likelihood/univariate_computeDstate.m     |  14 +-
 .../likelihood/univariate_kalman_filter.m     |  34 +-
 .../likelihood/univariate_kalman_filter_ss.m  |  26 +-
 matlab/lmmcp/catstruct.m                      |  18 +-
 matlab/lnsrch1.m                              |   2 +-
 matlab/lpdfgam.m                              |   2 +-
 matlab/lpdfgbeta.m                            |   2 +-
 matlab/lyapunov_solver.m                      |   2 +-
 matlab/lyapunov_symm.m                        |  14 +-
 matlab/marginal_density.m                     |   2 +-
 matlab/metropolis_hastings_initialization.m   |   4 +-
 matlab/mh_optimal_bandwidth.m                 |  12 +-
 matlab/missing/corrcoef/corrcoef.m            | 133 ++--
 .../missing/corrcoef/flag_implicit_skip_nan.m |  10 +-
 matlab/missing/corrcoef/sumskipnan.m          |  68 +--
 matlab/missing/corrcoef/tcdf.m                |   4 +-
 matlab/missing/ordeig/ordeig.m                |   2 +-
 matlab/missing/stats/betainv.m                |   2 +-
 matlab/missing/stats/corr.m                   |   4 +-
 matlab/missing/stats/gaminv.m                 |   2 +-
 matlab/mode_check.m                           |  12 +-
 matlab/model_diagnostics.m                    |   8 +-
 matlab/model_info.m                           | 108 ++--
 matlab/moment_function.m                      |   2 +-
 matlab/myboxplot.m                            |   6 +-
 matlab/mydelete.m                             |   6 +-
 matlab/occbin/call_solve_one_constraint.m     |   2 +-
 matlab/occbin/call_solve_two_constraints.m    |   2 +-
 matlab/occbin/get_deriv.m                     |   2 +-
 matlab/occbin/get_pq.m                        |   2 +-
 matlab/occbin/makechart.m                     |   6 +-
 matlab/occbin/makechart9.m                    |  18 +-
 matlab/occbin/map_regime.m                    |   2 +-
 matlab/occbin/mkdatap_anticipated.m           |   2 +-
 .../occbin/mkdatap_anticipated_2constraints.m |   2 +-
 matlab/occbin/solve_no_constraint_noclear.m   |   4 +-
 matlab/occbin/solve_one_constraint.m          |   4 +-
 matlab/occbin/solve_two_constraints.m         |   6 +-
 matlab/occbin/tokenize.m                      |   2 +-
 matlab/optimization/apprgrdn.m                |   2 +-
 matlab/optimization/cmaes.m                   |  46 +-
 matlab/optimization/csminit1.m                |   2 +-
 matlab/optimization/csminwel1.m               |   8 +-
 .../optimization/dynare_minimize_objective.m  |   4 +-
 matlab/optimization/gmhmaxlik.m               |   2 +-
 matlab/optimization/mr_gstep.m                |  10 +-
 matlab/optimization/mr_hessian.m              |  14 +-
 matlab/optimization/newrat.m                  |  20 +-
 .../simplex_optimization_routine.m            |   2 +-
 matlab/optimization/simpsa.m                  | 100 ++--
 matlab/optimization/simpsaget.m               |   2 +-
 matlab/optimization/simpsaset.m               |   4 +-
 matlab/optimization/simulated_annealing.m     | 166 ++---
 matlab/optimization/solvopt.m                 | 566 +++++++++++++-----
 matlab/optimize_prior.m                       |   2 +-
 .../AnalyseComputationalEnvironment.m         |  39 +-
 matlab/parallel/GiveCPUnumber.m               |   2 +-
 .../InitializeComputationalEnvironment.m      |  10 +-
 matlab/parallel/closeSlave.m                  |  27 +-
 matlab/parallel/distributeJobs.m              |   8 +-
 matlab/parallel/dynareParallelDelete.m        |  10 +-
 .../parallel/dynareParallelDeleteNewFiles.m   |   8 +-
 matlab/parallel/dynareParallelDir.m           |  24 +-
 matlab/parallel/dynareParallelGetFiles.m      |  24 +-
 matlab/parallel/dynareParallelGetNewFiles.m   |   6 +-
 matlab/parallel/dynareParallelListAllFiles.m  |   4 +-
 matlab/parallel/dynareParallelMkDir.m         |  16 +-
 matlab/parallel/dynareParallelRmDir.m         |  28 +-
 matlab/parallel/dynareParallelSendFiles.m     |  32 +-
 matlab/parallel/dynareParallelSnapshot.m      |   4 +-
 matlab/parallel/fMessageStatus.m              |   4 +-
 matlab/parallel/fParallel.m                   |  16 +-
 matlab/parallel/masterParallel.m              | 168 +++---
 matlab/parallel/slaveParallel.m               |  32 +-
 matlab/parallel/storeGlobalVars.m             |   4 +-
 matlab/parallel/struct2local.m                |   2 +-
 .../partial_information/PCL_Part_info_irf.m   |   2 +-
 .../PCL_Part_info_moments.m                   |   4 +-
 matlab/partial_information/PI_gensys.m        |   4 +-
 .../partial_information/PI_gensys_singularC.m |   5 +-
 .../add_auxiliary_variables_to_steadystate.m  |   4 +-
 matlab/partial_information/dr1_PI.m           |   4 +-
 .../det_cond_forecast.m                       | 170 +++---
 .../solve_stacked_problem.m                   |   2 +-
 matlab/plot_identification.m                  |  74 +--
 matlab/plot_priors.m                          |   4 +-
 matlab/plot_shock_decomposition.m             |  48 +-
 matlab/pm3.m                                  |  10 +-
 matlab/pm3_core.m                             |  12 +-
 matlab/posterior_sampler.m                    |  12 +-
 matlab/posterior_sampler_core.m               |   8 +-
 matlab/posterior_sampler_initialization.m     |   8 +-
 matlab/prior_draw.m                           |  14 +-
 matlab/prior_posterior_statistics.m           |  20 +-
 matlab/prior_posterior_statistics_core.m      |  40 +-
 matlab/priordens.m                            |  14 +-
 matlab/qzdiv.m                                |   4 +-
 matlab/realtime_shock_decomposition.m         |  24 +-
 matlab/reduced_rank_cholesky.m                |   2 +-
 matlab/resol.m                                |   2 +-
 matlab/rotated_slice_sampler.m                |  18 +-
 matlab/select_from_table.m                    |   2 +-
 matlab/set_state_space.m                      |   2 +-
 matlab/simulated_moment_uncertainty.m         |   6 +-
 matlab/simulated_moments_estimation.m         |   2 +-
 matlab/simult_.m                              |   4 +-
 matlab/slice_sampler.m                        |  12 +-
 matlab/smm_objective.m                        |   2 +-
 matlab/solve1.m                               |   2 +-
 matlab/solve_one_boundary.m                   |   2 +-
 matlab/solve_perfect_foresight_model.m        |   2 +-
 matlab/solve_two_boundaries.m                 |   6 +-
 matlab/stoch_simul.m                          |   2 +-
 matlab/stochastic_solvers.m                   |  10 +-
 matlab/th_autocovariances.m                   |  18 +-
 matlab/thet2tau.m                             |  16 +-
 matlab/trust_region.m                         |   2 +-
 matlab/user_has_matlab_license.m              |   4 +-
 matlab/utilities/dataset/lagged.m             |   8 +-
 matlab/utilities/dataset/quarterly2annual.m   |  20 +-
 matlab/utilities/graphics/colorspace.m        |  44 +-
 .../graphics/distinguishable_colors.m         |   4 +-
 matlab/ver_greater_than.m                     |   8 +-
 matlab/ver_less_than.m                        |   8 +-
 matlab/write_latex_parameter_table.m          |  12 +-
 matlab/writedata_text.m                       |   7 +-
 241 files changed, 2638 insertions(+), 2454 deletions(-)

diff --git a/matlab/AHessian.m b/matlab/AHessian.m
index 561c380a0..87e341643 100644
--- a/matlab/AHessian.m
+++ b/matlab/AHessian.m
@@ -39,7 +39,7 @@ function [AHess, DLIK, LIK] = AHessian(T,R,Q,H,P,Y,DT,DYss,DOm,DH,DP,start,mf,ka
 
 lik  = zeros(smpl,1);                           % Initialization of the vector gathering the densities.
 LIK  = Inf;                                     % Default value of the log likelihood.
-if nargout > 1,
+if nargout > 1
     DLIK  = zeros(k,1);                             % Initialization of the score.
 end
     AHess  = zeros(k,k);                             % Initialization of the Hessian
@@ -127,7 +127,7 @@ end
     end    
     
 AHess = -AHess;  
-if nargout > 1,
+if nargout > 1
     DLIK = DLIK/2;
 end
 % adding log-likelihhod constants
diff --git a/matlab/AIM/SPAimerr.m b/matlab/AIM/SPAimerr.m
index 2894a89a7..9bffb54aa 100644
--- a/matlab/AIM/SPAimerr.m
+++ b/matlab/AIM/SPAimerr.m
@@ -1,4 +1,4 @@
-function e = SPAimerr(c);
+function e = SPAimerr(c)
 % e = aimerr(c);
 %
 % Interpret the return codes generated by the aim routines.
diff --git a/matlab/AIM/SPAmalg.m b/matlab/AIM/SPAmalg.m
index 41307b445..6da8ac524 100644
--- a/matlab/AIM/SPAmalg.m
+++ b/matlab/AIM/SPAmalg.m
@@ -66,12 +66,12 @@ bcols=neq*nlag;q=zeros(qrows,qcols);rts=zeros(qcols,1);
 [h,q,iq,nexact]=SPExact_shift(h,q,iq,qrows,qcols,neq);
 if (iq>qrows)
     aimcode = 61;
-    return;
+    return
 end
 [h,q,iq,nnumeric]=SPNumeric_shift(h,q,iq,qrows,qcols,neq,condn);
 if (iq>qrows)
     aimcode = 62;
-    return;
+    return
 end
 [a,ia,js] = SPBuild_a(h,qcols,neq);
 if (ia ~= 0)
@@ -81,7 +81,7 @@ if (ia ~= 0)
         return 
     end 
     [w,rts,lgroots,flag_trouble]=SPEigensystem(a,uprbnd,min(length(js),qrows-iq+1));
-    if flag_trouble==1; 
+    if flag_trouble==1
         disp('Problem in SPEIG'); 
         aimcode=64;
         return
diff --git a/matlab/AIM/SPReduced_form.m b/matlab/AIM/SPReduced_form.m
index 3d5c88990..79ab3711d 100644
--- a/matlab/AIM/SPReduced_form.m
+++ b/matlab/AIM/SPReduced_form.m
@@ -1,4 +1,4 @@
-function [nonsing,b] = SPReduced_form(q,qrows,qcols,bcols,neq,condn);
+function [nonsing,b] = SPReduced_form(q,qrows,qcols,bcols,neq,condn)
 % [nonsing,b] = SPReduced_form(q,qrows,qcols,bcols,neq,b,condn);
 %
 % Compute reduced-form coefficient matrix, b.
diff --git a/matlab/AIM_first_order_solver.m b/matlab/AIM_first_order_solver.m
index fb3a99dc6..94d8e3845 100644
--- a/matlab/AIM_first_order_solver.m
+++ b/matlab/AIM_first_order_solver.m
@@ -91,7 +91,7 @@ function [dr,info]=AIM_first_order_solver(jacobia,M,dr,qz_criterium)
         if nba > nsfwrd
             temp = temp(nd-nba+1:nd-nsfwrd)-1-qz_criterium;
             info(1) = 3;
-        elseif nba < nsfwrd;
+        elseif nba < nsfwrd
             temp = temp(nd-nsfwrd+1:nd-nba)-1-qz_criterium;
             info(1) = 4;
         end
diff --git a/matlab/GetPosteriorParametersStatistics.m b/matlab/GetPosteriorParametersStatistics.m
index a7c910621..04648ea32 100644
--- a/matlab/GetPosteriorParametersStatistics.m
+++ b/matlab/GetPosteriorParametersStatistics.m
@@ -163,7 +163,7 @@ if nvx
         end
         disp(sprintf(pformat,header_width,name,bayestopt_.p1(ip),post_mean,hpd_interval,...
                      pnames(bayestopt_.pshape(ip)+1,:),bayestopt_.p2(ip)));
-        if TeX,
+        if TeX
             name = deblank(M_.exo_names_tex(k,:));
             TeXCore(fid,name,deblank(pnames(bayestopt_.pshape(ip)+1,:)),bayestopt_.p1(ip),...
                     bayestopt_.p2(ip),post_mean,sqrt(post_var),hpd_interval);
@@ -311,7 +311,7 @@ if ncn
         end
         disp(sprintf(pformat, header_width,name,bayestopt_.p1(ip),post_mean,hpd_interval, ...
                      pnames(bayestopt_.pshape(ip)+1,:),bayestopt_.p2(ip)));
-        if TeX,
+        if TeX
             name = ['(',deblank(M_.endo_names_tex(k1,:)) ',' deblank(M_.endo_names_tex(k2,:)),')'];
             TeXCore(fid,name,deblank(pnames(bayestopt_.pshape(ip)+1,:)),bayestopt_.p1(ip),...
                     bayestopt_.p2(ip),post_mean,sqrt(post_var),hpd_interval);            
diff --git a/matlab/PlotPosteriorDistributions.m b/matlab/PlotPosteriorDistributions.m
index d2e89ea00..4358b07e4 100644
--- a/matlab/PlotPosteriorDistributions.m
+++ b/matlab/PlotPosteriorDistributions.m
@@ -151,7 +151,7 @@ for i=1:npar
     title(nam,'Interpreter','none');
     hold off;
     drawnow
-    if subplotnum == MaxNumberOfPlotPerFigure || i == npar;
+    if subplotnum == MaxNumberOfPlotPerFigure || i == npar
         dyn_saveas(hfig,[OutputDirectoryName '/' M_.fname '_PriorsAndPosteriors' int2str(figunumber)],options_.nodisplay,options_.graph_format);
         if TeX && any(strcmp('eps',cellstr(options_.graph_format)))
             fprintf(fidTeX,'\\begin{figure}[H]\n');
diff --git a/matlab/PosteriorIRF.m b/matlab/PosteriorIRF.m
index c0d393d4e..f0764f2a3 100644
--- a/matlab/PosteriorIRF.m
+++ b/matlab/PosteriorIRF.m
@@ -178,7 +178,7 @@ if strcmpi(type,'posterior')
     end
 end
 
-if ~strcmpi(type,'prior'),
+if ~strcmpi(type,'prior')
     localVars.x=x;
 end
 
@@ -202,16 +202,16 @@ localVars.ifil2=ifil2;
 localVars.MhDirectoryName=MhDirectoryName;
 
 % Like sequential execution!
-if isnumeric(options_.parallel),
+if isnumeric(options_.parallel)
     [fout] = PosteriorIRF_core1(localVars,1,B,0);
     nosaddle = fout.nosaddle;
 else
     % Parallel execution!
     [nCPU, totCPU, nBlockPerCPU] = distributeJobs(options_.parallel, 1, B);
-    for j=1:totCPU-1,
+    for j=1:totCPU-1
         nfiles = ceil(nBlockPerCPU(j)/MAX_nirfs_dsge);
         NumberOfIRFfiles_dsge(j+1) =NumberOfIRFfiles_dsge(j)+nfiles;
-        if MAX_nirfs_dsgevar,
+        if MAX_nirfs_dsgevar
             nfiles = ceil(nBlockPerCPU(j)/MAX_nirfs_dsgevar);
         else
             nfiles=0;
@@ -236,8 +236,8 @@ else
     NamFileInput(1,:) = {'',[M_.fname '_static.m']};
     NamFileInput(2,:) = {'',[M_.fname '_dynamic.m']};
     NamFileInput(3,:) = {'',[M_.fname '_set_auxiliary_variables.m']};
-    if options_.steadystate_flag,
-        if options_.steadystate_flag == 1,
+    if options_.steadystate_flag
+        if options_.steadystate_flag == 1
             NamFileInput(length(NamFileInput)+1,:)={'',[M_.fname '_steadystate.m']};
         else
             NamFileInput(length(NamFileInput)+1,:)={'',[M_.fname '_steadystate2.m']};
@@ -245,7 +245,7 @@ else
     end
     [fout] = masterParallel(options_.parallel, 1, B,NamFileInput,'PosteriorIRF_core1', localVars, globalVars, options_.parallel_info);
     nosaddle=0;
-    for j=1:length(fout),
+    for j=1:length(fout)
         nosaddle = nosaddle + fout(j).nosaddle;
     end
 
@@ -443,11 +443,11 @@ end
 
 % Comment for testing!
 if ~isoctave
-    if isnumeric(options_.parallel)  || (M_.exo_nbr*ceil(size(varlist,1)/MaxNumberOfPlotPerFigure))<8,
+    if isnumeric(options_.parallel)  || (M_.exo_nbr*ceil(size(varlist,1)/MaxNumberOfPlotPerFigure))<8
         [fout] = PosteriorIRF_core2(localVars,1,M_.exo_nbr,0);
     else
         isRemoteOctave = 0;
-        for indPC=1:length(options_.parallel),
+        for indPC=1:length(options_.parallel)
             isRemoteOctave = isRemoteOctave + (findstr(options_.parallel(indPC).MatlabOctavePath, 'octave'));
         end
         if isRemoteOctave
diff --git a/matlab/PosteriorIRF_core1.m b/matlab/PosteriorIRF_core1.m
index 37f98209b..8c74eb8c2 100644
--- a/matlab/PosteriorIRF_core1.m
+++ b/matlab/PosteriorIRF_core1.m
@@ -43,7 +43,7 @@ function myoutput=PosteriorIRF_core1(myinputs,fpar,B,whoiam, ThisMatlab)
 
 global options_ estim_params_ oo_ M_ bayestopt_ dataset_ dataset_info
 
-if nargin<4,
+if nargin<4
     whoiam=0;
 end
 
@@ -55,7 +55,7 @@ irun =myinputs.irun;
 irun2=myinputs.irun2;
 npar=myinputs.npar;
 type=myinputs.type;
-if ~strcmpi(type,'prior'),
+if ~strcmpi(type,'prior')
     x=myinputs.x;
 end
 
@@ -102,7 +102,7 @@ end
 RemoteFlag = 0;
 
 if whoiam
-    if Parallel(ThisMatlab).Local==0,
+    if Parallel(ThisMatlab).Local==0
         RemoteFlag =1;
     end
     prct0={0,whoiam,Parallel(ThisMatlab)};
@@ -165,7 +165,7 @@ while fpar<B
         elseif info(1) == 5
             errordef = 'Rank condition  is not satisfied';
         end
-        if strcmpi(type,'prior'),
+        if strcmpi(type,'prior')
             disp(['PosteriorIRF :: Dynare is unable to solve the model (' errordef ')'])
             continue
         else
@@ -240,9 +240,9 @@ while fpar<B
         else
             stock_irf_bvardsge(:,:,:,IRUN) = reshape(tmp_dsgevar,options_.irf,dataset_.vobs,M_.exo_nbr);
             instr = [MhDirectoryName '/' M_.fname '_irf_bvardsge' ...
-                     int2str(NumberOfIRFfiles_dsgevar) '.mat stock_irf_bvardsge;'];,
+                     int2str(NumberOfIRFfiles_dsgevar) '.mat stock_irf_bvardsge;'];
             eval(['save ' instr]);
-            if RemoteFlag==1,
+            if RemoteFlag==1
                 OutputFileName_bvardsge = [OutputFileName_bvardsge; {[MhDirectoryName filesep], [M_.fname '_irf_bvardsge' int2str(NumberOfIRFfiles_dsgevar) '.mat']}];
             end
             NumberOfIRFfiles_dsgevar = NumberOfIRFfiles_dsgevar+1;
@@ -259,14 +259,14 @@ while fpar<B
                          int2str(NumberOfIRFfiles_dsgevar) '.mat stock_irf_bvardsge;'];
                 eval(['save ' instr]);
                 NumberOfIRFfiles_dsgevar = NumberOfIRFfiles_dsgevar+1;
-                if RemoteFlag==1,
+                if RemoteFlag==1
                     OutputFileName_bvardsge = [OutputFileName_bvardsge; {[MhDirectoryName filesep], [M_.fname '_irf_bvardsge' int2str(NumberOfIRFfiles_dsgevar) '.mat']}];
                 end
                 irun = 0;
             end
         end
         save([MhDirectoryName '/' M_.fname '_irf_dsge' int2str(NumberOfIRFfiles_dsge) '.mat'],'stock_irf_dsge');
-        if RemoteFlag==1,
+        if RemoteFlag==1
             OutputFileName_dsge = [OutputFileName_dsge; {[MhDirectoryName filesep], [M_.fname '_irf_dsge' int2str(NumberOfIRFfiles_dsge) '.mat']}];
         end
         NumberOfIRFfiles_dsge = NumberOfIRFfiles_dsge+1;
@@ -278,7 +278,7 @@ while fpar<B
         end
         stock = stock_param;
         save([MhDirectoryName '/' M_.fname '_param_irf' int2str(ifil2) '.mat'],'stock');
-        if RemoteFlag==1,
+        if RemoteFlag==1
             OutputFileName_param = [OutputFileName_param; {[MhDirectoryName filesep], [M_.fname '_param_irf' int2str(ifil2) '.mat']}];
         end
         ifil2 = ifil2 + 1;
diff --git a/matlab/PosteriorIRF_core2.m b/matlab/PosteriorIRF_core2.m
index abf1c3cbd..9f922a409 100644
--- a/matlab/PosteriorIRF_core2.m
+++ b/matlab/PosteriorIRF_core2.m
@@ -49,7 +49,7 @@ function myoutput=PosteriorIRF_core2(myinputs,fpar,npar,whoiam,ThisMatlab)
 
 global options_  M_
 
-if nargin<4,
+if nargin<4
     whoiam=0;
 end
 
@@ -85,8 +85,8 @@ end
 DirectoryName = CheckPath('Output',M_.dname);
 
 RemoteFlag = 0;
-if whoiam,
-    if Parallel(ThisMatlab).Local==0,
+if whoiam
+    if Parallel(ThisMatlab).Local==0
         RemoteFlag =1;
     end
     prct0={0,whoiam,Parallel(ThisMatlab)};
@@ -96,7 +96,7 @@ end
 OutputFileName={};
 
 subplotnum = 0;
-for i=fpar:npar,
+for i=fpar:npar
     figunumber = 0;
 
     for j=1:nvar
@@ -153,13 +153,13 @@ for i=fpar:npar,
         if subplotnum == MaxNumberOfPlotPerFigure || (j == nvar  && subplotnum> 0)
             figunumber = figunumber+1;
             dyn_saveas(hh,[DirectoryName '/'  M_.fname '_Bayesian_IRF_' deblank(tit(i,:)) '_' int2str(figunumber)],options_.nodisplay,options_.graph_format);
-            if RemoteFlag==1,
+            if RemoteFlag==1
                 OutputFileName = [OutputFileName; {[DirectoryName,filesep], [M_.fname '_Bayesian_IRF_' deblank(tit(i,:)) '_' int2str(figunumber) '.*']}];
             end
             subplotnum = 0;
         end
     end% loop over selected endo_var
-    if whoiam,
+    if whoiam
         fprintf('Done! \n');
         waitbarString = [ 'Exog. shocks ' int2str(i) '/' int2str(npar) ' done.'];
 %         fMessageStatus((i-fpar+1)/(npar-fpar+1),whoiam,waitbarString, waitbarTitle, Parallel(ThisMatlab));
diff --git a/matlab/ReshapeMatFiles.m b/matlab/ReshapeMatFiles.m
index 1ad90fce1..8b6c53c06 100644
--- a/matlab/ReshapeMatFiles.m
+++ b/matlab/ReshapeMatFiles.m
@@ -44,15 +44,15 @@ function ReshapeMatFiles(type, type2)
 
 global M_ options_
 
-if nargin==1, 
+if nargin==1
     MhDirectoryName = [ CheckPath('metropolis',M_.dname) filesep ];
 else
     if strcmpi(type2,'posterior')
         MhDirectoryName = [CheckPath('metropolis',M_.dname) filesep ];
     elseif strcmpi(type2,'gsa')
-        if options_.opt_gsa.morris==1,
+        if options_.opt_gsa.morris==1
             MhDirectoryName = [CheckPath('gsa/screen',M_.dname) filesep ];
-        elseif options_.opt_gsa.morris==2,
+        elseif options_.opt_gsa.morris==2
             MhDirectoryName = [CheckPath('gsa/identif',M_.dname) filesep ];
         elseif options_.opt_gsa.pprior
             MhDirectoryName = [CheckPath(['gsa' filesep 'prior'],M_.dname) filesep ];
diff --git a/matlab/UnivariateSpectralDensity.m b/matlab/UnivariateSpectralDensity.m
index ab00d1856..d5a37f24f 100644
--- a/matlab/UnivariateSpectralDensity.m
+++ b/matlab/UnivariateSpectralDensity.m
@@ -134,7 +134,7 @@ for ig = 1:ngrid
     g_omega = [aa*tneg(ig) bb]*f_omega*[aa'*tpos(ig); bb']; % selected variables
     f_hp = filter_gain(ig)^2*g_omega; % spectral density of selected filtered series
     mathp_col(ig,:) = (f_hp(:))';    % store as matrix row
-end;
+end
 
 f = zeros(nvar,ngrid);
 for i=1:nvar
diff --git a/matlab/WriteShockDecomp2Excel.m b/matlab/WriteShockDecomp2Excel.m
index dff5c79bb..618a6b064 100644
--- a/matlab/WriteShockDecomp2Excel.m
+++ b/matlab/WriteShockDecomp2Excel.m
@@ -42,7 +42,7 @@ end
 % number of components equals number of shocks + 1 (initial conditions)
 comp_nbr = size(z,2)-1;
 
-if nargin==8 ,    
+if nargin==8
     if isfield(opts_decomp,'steady_state')
         SteadyState = opts_decomp.steady_state;
     end
@@ -84,7 +84,7 @@ end
 nvar = length(i_var);
 
 labels = char(char(shock_names),'Initial values');
-if ~(screen_shocks && comp_nbr>18),
+if ~(screen_shocks && comp_nbr>18)
     screen_shocks=0;
 end
 comp_nbr0=comp_nbr;
@@ -92,7 +92,7 @@ comp_nbr0=comp_nbr;
 for j=1:nvar
     d0={};
     z1 = squeeze(z(i_var(j),:,:));
-    if screen_shocks,
+    if screen_shocks
         [junk, isort] = sort(mean(abs(z1(1:end-2,:)')), 'descend');
         labels = char(char(shock_names(isort(1:16),:)),'Others', 'Initial values');
         zres = sum(z1(isort(17:end),:),1);
@@ -107,7 +107,7 @@ for j=1:nvar
         d0(LastRow+2,1)={'Legend.'};
         d0(LastRow+2,2)={'Shocks include:'};
         d0(LastRow+3:LastRow+3+comp_nbr-1,1)=cellstr(labels(1:comp_nbr,:));
-        for ic=1:comp_nbr,
+        for ic=1:comp_nbr
             group_members = shock_groups.(shock_ind{ic}).shocks;
             d0(LastRow+2+ic,2:1+length(group_members))=group_members;
         end
diff --git a/matlab/annualized_shock_decomposition.m b/matlab/annualized_shock_decomposition.m
index 9590699b3..f5ee9c8e6 100644
--- a/matlab/annualized_shock_decomposition.m
+++ b/matlab/annualized_shock_decomposition.m
@@ -75,7 +75,7 @@ if isfield(q2a,'name')
     if isfield(q2a,'tex_name')
         mytex = q2a.tex_name;
     end
-    if mytype==2,
+    if mytype==2
         gtxt = ['PHI' mytxt]; % inflation rate
         gtex = ['{\pi(' mytex ')}'];
     elseif mytype
@@ -101,7 +101,7 @@ if isstruct(aux)
     end
     yaux=aux.y;
 end
-if mytype==2,
+if mytype==2
     gtxt = 'PHI'; % inflation rate
     gtex = '\pi';
 elseif mytype
@@ -115,7 +115,7 @@ nterms = size(z,2);
 nfrcst = opts.forecast/4;
 
 for j=1:nvar
-    if j>1,
+    if j>1
         endo_names = char(endo_names,[deblank(M_.endo_names(i_var(j),:)) '_A']);
         endo_names_tex = char(endo_names_tex,['{' deblank(M_.endo_names_tex(i_var(j),:)) '}^A']);
         gendo_names = char(gendo_names,[gtxt endo_names(j,:)]);
@@ -133,15 +133,15 @@ for j=1:nvar
             gendo_names_tex = [gtex '(' deblank(endo_names_tex(j,:)) ')'];
         end
     end
-    for k =1:nterms,
-        if isstruct(aux),
+    for k =1:nterms
+        if isstruct(aux)
             aux.y = squeeze(yaux(j,k,min((t0-3):-4:1):end));
         end
         [za(j,k,:), steady_state_a(j,1), gza(j,k,:), steady_state_ga(j,1)] = ...
             quarterly2annual(squeeze(z(j,k,min((t0-3):-4:1):end)),steady_state(j),GYTREND0,var_type,islog,aux);
     end
     ztmp=squeeze(za(j,:,:));
-    if cumfix==0,
+    if cumfix==0
         zscale = sum(ztmp(1:end-1,:))./ztmp(end,:);
         ztmp(1:end-1,:) = ztmp(1:end-1,:)./repmat(zscale,[nterms-1,1]);
     else
@@ -149,7 +149,7 @@ for j=1:nvar
         ztmp(end-1,:) = ztmp(end-1,:) + zres;
     end
     gztmp=squeeze(gza(j,:,:));
-    if cumfix==0,
+    if cumfix==0
         gscale = sum(gztmp(1:end-1,:))./ gztmp(end,:);
         gztmp(1:end-1,:) = gztmp(1:end-1,:)./repmat(gscale,[nterms-1,1]);
     else
@@ -160,7 +160,7 @@ for j=1:nvar
     gza(j,:,:) = gztmp;
 end
 
-if q2a.plot ==1,
+if q2a.plot ==1
     z=gza;
     endo_names = gendo_names;
     endo_names_tex = gendo_names_tex;
@@ -176,9 +176,9 @@ end
 % end
 
 % realtime
-if realtime_ && isstruct(oo_) && isfield(oo_, 'realtime_shock_decomposition'),
+if realtime_ && isstruct(oo_) && isfield(oo_, 'realtime_shock_decomposition')
 init=1;
-for i=t0:4:t1,
+for i=t0:4:t1
     yr=floor(i/4);
     za=[];
     gza=[];
@@ -202,13 +202,13 @@ end
 %     z = z(i_var,:,:);
            
     for j=1:nvar
-        for k =nterms:-1:1,
+        for k =nterms:-1:1
 %             if k<nterms
 %                 ztmp = squeeze(sum(z(j,[1:k-1,k+1:end-1],t0-4:end)));
 %             else
                 ztmp = squeeze(z(j,k,min((t0-3):-4:1):end));
 %             end
-            if isstruct(aux),
+            if isstruct(aux)
                 aux.y = squeeze(yaux(j,k,min((t0-3):-4:1):end));
             end
             [za(j,k,:), steady_state_a(j,1), gza(j,k,:), steady_state_ga(j,1)] = ...
@@ -222,7 +222,7 @@ end
         
         ztmp=squeeze(za(j,:,:));
 
-        if cumfix==0,
+        if cumfix==0
             zscale = sum(ztmp(1:end-1,:))./ztmp(end,:);
             ztmp(1:end-1,:) = ztmp(1:end-1,:)./repmat(zscale,[nterms-1,1]);
         else
@@ -231,7 +231,7 @@ end
         end
         
         gztmp=squeeze(gza(j,:,:));
-        if cumfix==0,
+        if cumfix==0
             gscale = sum(gztmp(1:end-1,:))./ gztmp(end,:);
             gztmp(1:end-1,:) = gztmp(1:end-1,:)./repmat(gscale,[nterms-1,1]);
         else
@@ -243,7 +243,7 @@ end
         gza(j,:,:) = gztmp;
     end
     
-    if q2a.plot ==1,
+    if q2a.plot ==1
         z=gza;
     elseif q2a.plot == 2
         z=za;
@@ -251,7 +251,7 @@ end
         z=cat(1,za,gza);
     end
     
-    if init==1,
+    if init==1
         oo_.annualized_realtime_shock_decomposition.pool = z;
     else
         oo_.annualized_realtime_shock_decomposition.pool(:,:,yr) = z(:,:,end-nfrcst);
@@ -272,7 +272,7 @@ end
             oo_.annualized_realtime_conditional_shock_decomposition.(['yr_' int2str(yr-nfrcst)])(:,end,:) = ...
                 oo_.annualized_realtime_shock_decomposition.pool(:,end,yr-nfrcst:end);
             if i==t1
-                for my_forecast_=(nfrcst-1):-1:1,
+                for my_forecast_=(nfrcst-1):-1:1
                     oo_.annualized_realtime_conditional_shock_decomposition.(['yr_' int2str(yr-my_forecast_)]) = ...
                         oo_.annualized_realtime_shock_decomposition.pool(:,:,yr-my_forecast_:yr) - ...
                         oo_.annualized_realtime_forecast_shock_decomposition.(['yr_' int2str(yr-my_forecast_)])(:,:,1:my_forecast_+1);
@@ -320,12 +320,12 @@ switch realtime_
 end
 end
 
-if q2a.plot ==0,
+if q2a.plot ==0
     i_var=1:2*nvar;
     steady_state = [steady_state_a;steady_state_ga];
 else
     i_var=1:nvar;
-    if q2a.plot ==1,
+    if q2a.plot ==1
         steady_state = steady_state_ga;
     else
         steady_state = steady_state_a;
diff --git a/matlab/basic_plan.m b/matlab/basic_plan.m
index c7b4cb360..fb8847c8b 100644
--- a/matlab/basic_plan.m
+++ b/matlab/basic_plan.m
@@ -38,7 +38,7 @@ function plan = basic_plan(plan, exogenous, expectation_type, date, value)
   ix = find(strcmp(exogenous, plan.exo_names));
   if  isempty(ix)
       error(['in basic_plan the second argument ' exogenous ' is not an exogenous variable']);
-  end;
+  end
   sdate = length(date);
   if sdate > 1
       if date(1) < plan.date(1) || date(end) > plan.date(end)
diff --git a/matlab/check_posterior_sampler_options.m b/matlab/check_posterior_sampler_options.m
index 1980c0a79..199ac2369 100644
--- a/matlab/check_posterior_sampler_options.m
+++ b/matlab/check_posterior_sampler_options.m
@@ -32,11 +32,11 @@ function [posterior_sampler_options, options_] = check_posterior_sampler_options
 
 
 init=0;
-if isempty(posterior_sampler_options),
+if isempty(posterior_sampler_options)
     init=1;
 end
 
-if init,
+if init
     % set default options and user defined options
     posterior_sampler_options.posterior_sampling_method = options_.posterior_sampler_options.posterior_sampling_method;
     posterior_sampler_options.bounds = bounds;
@@ -253,7 +253,7 @@ if init,
                             % This will automatically trigger <rotated>
                             % default = []
                             tmp_mode = options_list{i,2};
-                            for j=1:size(tmp_mode,2),
+                            for j=1:size(tmp_mode,2)
                                 posterior_sampler_options.mode(j).m = tmp_mode(:,j);
                             end
                             
@@ -328,7 +328,7 @@ if init,
                 end
             end
             
-            if any(isinf(bounds.lb)) || any(isinf(bounds.ub)),
+            if any(isinf(bounds.lb)) || any(isinf(bounds.ub))
                 skipline()
                 disp('some priors are unbounded and prior_trunc is set to zero')
                 error('The option "slice" is inconsistent with prior_trunc=0.')
@@ -347,21 +347,21 @@ if init,
             
             
             posterior_sampler_options.W1=posterior_sampler_options.initial_step_size*(bounds.ub-bounds.lb);
-            if options_.load_mh_file,
+            if options_.load_mh_file
                 posterior_sampler_options.slice_initialize_with_mode = 0;
             else
-                if ~posterior_sampler_options.slice_initialize_with_mode,
+                if ~posterior_sampler_options.slice_initialize_with_mode
                     posterior_sampler_options.invhess=[];
                 end
             end
             
-            if ~isempty(posterior_sampler_options.mode_files), % multimodal case
+            if ~isempty(posterior_sampler_options.mode_files) % multimodal case
                 modes = posterior_sampler_options.mode_files; % these can be also mean files from previous parallel slice chains
                 load(modes, 'xparams')
-                if size(xparams,2)<2,
+                if size(xparams,2)<2
                     error(['check_posterior_sampler_options:: Variable xparams loaded in file <' modes '> has size [' int2str(size(xparams,1)) 'x' int2str(size(xparams,2)) ']: it must contain at least two columns, to allow multi-modal sampling.'])
                 end
-                for j=1:size(xparams,2),
+                for j=1:size(xparams,2)
                     mode(j).m=xparams(:,j);
                 end
                 posterior_sampler_options.mode = mode;
@@ -386,7 +386,7 @@ if ~strcmp(posterior_sampler_options.posterior_sampling_method,'slice')
     end
 end
 
-if options_.load_mh_file && posterior_sampler_options.use_mh_covariance_matrix,
+if options_.load_mh_file && posterior_sampler_options.use_mh_covariance_matrix
     [junk, invhess] = compute_mh_covariance_matrix;
     posterior_sampler_options.invhess = invhess;
 end
@@ -396,10 +396,8 @@ end
 % check specific options for slice sampler
 if strcmp(posterior_sampler_options.posterior_sampling_method,'slice')
     invhess = posterior_sampler_options.invhess;
-    
-    if posterior_sampler_options.rotated,
-        if isempty(posterior_sampler_options.mode_files) && isempty(posterior_sampler_options.mode), % rotated unimodal
-            
+    if posterior_sampler_options.rotated
+        if isempty(posterior_sampler_options.mode_files) && isempty(posterior_sampler_options.mode) % rotated unimodal
             if ~options_.cova_compute && ~(options_.load_mh_file && posterior_sampler_options.use_mh_covariance_matrix)
                 skipline()
                 disp('check_posterior_sampler_options:: I cannot start rotated slice sampler because')
@@ -419,19 +417,13 @@ if strcmp(posterior_sampler_options.posterior_sampling_method,'slice')
             posterior_sampler_options.WR=sqrt(diag(D))*3;
         end
     else
-        if ~options_.load_mh_file && ~posterior_sampler_options.slice_initialize_with_mode,
+        if ~options_.load_mh_file && ~posterior_sampler_options.slice_initialize_with_mode
             posterior_sampler_options.invhess=[];
         end
     end
-    
     % needs to be re-set to zero otherwise posterior analysis is filtered
     % out in dynare_estimation_1.m
     options_.mh_posterior_mode_estimation = 0;
-    
-    
-else
-    
-    
 end
 
 return
diff --git a/matlab/chol_SE.m b/matlab/chol_SE.m
index 0ec5a900b..ae02493f0 100644
--- a/matlab/chol_SE.m
+++ b/matlab/chol_SE.m
@@ -293,16 +293,16 @@ function  g=gersh_nested(A,j,n)
 
 g=zeros(n,1);
 for ii = j:n
-    if ii == 1;
+    if ii == 1
         sum_up_to_i = 0;
     else
         sum_up_to_i = sum(abs(A(ii,j:(ii-1))));
-    end;
-    if ii == n;
+    end
+    if ii == n
         sum_after_i = 0;
     else
         sum_after_i = sum(abs(A((ii+1):n,ii)));
-    end;
+    end
     g(ii) = sum_up_to_i + sum_after_i- A(ii,ii);
 end
 end
diff --git a/matlab/convergence_diagnostics/McMCDiagnostics.m b/matlab/convergence_diagnostics/McMCDiagnostics.m
index c42467d31..769b70d35 100644
--- a/matlab/convergence_diagnostics/McMCDiagnostics.m
+++ b/matlab/convergence_diagnostics/McMCDiagnostics.m
@@ -101,7 +101,7 @@ end
 my_title='MCMC Inefficiency factors per block';
 IFAC_header='Parameter';
 IFAC_header_tex='Parameter';
-for j=1:nblck,
+for j=1:nblck
     IFAC_header = char(IFAC_header,['Block ' int2str(j)]);
     IFAC_header_tex = char(IFAC_header_tex,['Block~' int2str(j)]);
 end
@@ -220,7 +220,7 @@ if nblck == 1 % Brooks and Gelman tests need more than one block
         end      
     end
        
-    return;
+    return
 end
 
 Origin = 1000;
@@ -262,7 +262,7 @@ localVars.M_ = M_;
 
 
 % Like sequential execution!
-if isnumeric(options_.parallel),
+if isnumeric(options_.parallel)
     fout = McMCDiagnostics_core(localVars,1,npar,0);
     UDIAG = fout.UDIAG;
     clear fout
@@ -276,7 +276,7 @@ else
     
     [fout, nBlockPerCPU, totCPU] = masterParallel(options_.parallel, 1, npar,NamFileInput,'McMCDiagnostics_core', localVars, [], options_.parallel_info);
     UDIAG = fout(1).UDIAG;
-    for j=2:totCPU,
+    for j=2:totCPU
         UDIAG = cat(3,UDIAG ,fout(j).UDIAG);
     end
 end
@@ -346,7 +346,7 @@ if reste
     if reste == 1
         nr = 3;
         nc = 1;
-    elseif reste == 2;
+    elseif reste == 2
         nr = 2;
         nc = 3;
     end
@@ -391,7 +391,7 @@ if reste
     dyn_saveas(h,[ OutputFolder '/' ModelName '_udiag' int2str(pages+1)],options_.nodisplay,options_.graph_format);
     if TeX && any(strcmp('eps',cellstr(options_.graph_format)))
         fprintf(fidTeX,'\\begin{figure}[H]\n');
-        for jj = 1:size(NAMES,1);
+        for jj = 1:size(NAMES,1)
             fprintf(fidTeX,'\\psfrag{%s}[1][][0.5][0]{%s}\n',deblank(NAMES(jj,:)),deblank(TEXNAMES(jj,:)));
         end    
         fprintf(fidTeX,'\\centering \n');
diff --git a/matlab/convergence_diagnostics/McMCDiagnostics_core.m b/matlab/convergence_diagnostics/McMCDiagnostics_core.m
index af41566c9..db1673da2 100644
--- a/matlab/convergence_diagnostics/McMCDiagnostics_core.m
+++ b/matlab/convergence_diagnostics/McMCDiagnostics_core.m
@@ -50,7 +50,7 @@ function myoutput = McMCDiagnostics_core(myinputs,fpar,npar,whoiam, ThisMatlab)
 % You should have received a copy of the GNU General Public License
 % along with Dynare.  If not, see <http://www.gnu.org/licenses/>.
 
-if nargin<4,
+if nargin<4
     whoiam=0;
 end
 
@@ -71,7 +71,7 @@ M_=myinputs.M_;
 if whoiam
     Parallel=myinputs.Parallel;
 end
-if ~exist('MetropolisFolder'),
+if ~exist('MetropolisFolder')
     MetropolisFolder = CheckPath('metropolis',M_.dname);
 end
 
@@ -81,16 +81,16 @@ UDIAG = zeros(NumberOfLines,6,npar-fpar+1);
 
 if whoiam
     waitbarString = ['Please wait... McMCDiagnostics (' int2str(fpar) 'of' int2str(npar) ')...'];
-    if Parallel(ThisMatlab).Local,
+    if Parallel(ThisMatlab).Local
         waitbarTitle=['Local '];
     else
         waitbarTitle=[Parallel(ThisMatlab).ComputerName];
     end
     fMessageStatus(0,whoiam,waitbarString, waitbarTitle, Parallel(ThisMatlab));
 end
-for j=fpar:npar,
+for j=fpar:npar
     if isoctave
-        if (whoiam==0),
+        if (whoiam==0)
             printf('    Parameter %d...  ',j);
         end
     else
@@ -131,13 +131,13 @@ for j=fpar:npar,
         end
     end
     if isoctave
-        if (whoiam==0),
+        if (whoiam==0)
             printf('Done! \n');
         end
     else
         fprintf('Done! \n');
     end
-    if whoiam,
+    if whoiam
         waitbarString = [ 'Parameter ' int2str(j) '/' int2str(npar) ' done.'];
         fMessageStatus((j-fpar+1)/(npar-fpar+1),whoiam,waitbarString, waitbarTitle, Parallel(ThisMatlab))
     end
diff --git a/matlab/convergence_diagnostics/geweke_chi2_test.m b/matlab/convergence_diagnostics/geweke_chi2_test.m
index 7ed383139..bfd80a573 100644
--- a/matlab/convergence_diagnostics/geweke_chi2_test.m
+++ b/matlab/convergence_diagnostics/geweke_chi2_test.m
@@ -57,7 +57,7 @@ function results_struct = geweke_chi2_test(results1,results2,results_struct,opti
 % based on code by James P. LeSage, who in turn 
 % drew on MATLAB programs written by Siddartha Chib 
 
-for k=1:length(options.convergence.geweke.taper_steps)+1;
+for k=1:length(options.convergence.geweke.taper_steps)+1
   NSE=[results1(:,3+(k-1)*2) results2(:,3+(k-1)*2)];
   means=[results1(:,1) results2(:,1)];
   diff_Means=means(:,1)-means(:,2);
@@ -70,5 +70,5 @@ for k=1:length(options.convergence.geweke.taper_steps)+1;
   results_struct.pooled_mean(:,k) = pooled_mean;
   results_struct.pooled_nse(:,k) = pooled_NSE;
   results_struct.prob_chi2_test(:,k) = p;
-end;
+end
 
diff --git a/matlab/convergence_diagnostics/geweke_moments.m b/matlab/convergence_diagnostics/geweke_moments.m
index 242a9d550..4acf2cf19 100644
--- a/matlab/convergence_diagnostics/geweke_moments.m
+++ b/matlab/convergence_diagnostics/geweke_moments.m
@@ -64,10 +64,10 @@ n_draws_used = ns*n_groups; %effective number of draws used after rounding down
 
 window_means= zeros(n_groups,1);
 window_uncentered_variances= zeros(n_groups,1);
-for ig=1:n_groups;
+for ig=1:n_groups
     window_means(ig,1)=sum(draws((ig-1)*ns+1:ig*ns,1))/ns;
     window_uncentered_variances(ig,1)=sum(draws((ig-1)*ns+1:ig*ns,1).^2)/ns;        
-end; %for ig
+end %for ig
 total_mean=mean(window_means);
 total_variance=mean(window_uncentered_variances)-total_mean^2;
 
@@ -88,9 +88,9 @@ results_struct.rne_iid = results_vec(1,4);
 %get autocovariance of grouped means
 centered_window_means=window_means-total_mean;
 autocov_grouped_means=zeros(n_groups,1);
-for lag=0:n_groups-1;
+for lag=0:n_groups-1
     autocov_grouped_means(lag+1)=centered_window_means(lag+1:n_groups,1)'*centered_window_means(1:n_groups-lag,1)/100;
-end;
+end
 
 % numerical standard error with tapered autocovariance functions
 for taper_index=1:length(taper_steps)
@@ -105,5 +105,5 @@ for taper_index=1:length(taper_steps)
 
     eval(['results_struct.nse_taper_',num2str(taper),'= NSE_taper;']);
     eval(['results_struct.rne_taper_',num2str(taper),'= total_variance/(n_draws_used*NSE_taper^2);']);
-end; % end of for mm loop
+end % end of for mm loop
 
diff --git a/matlab/convergence_diagnostics/mcmc_ifac.m b/matlab/convergence_diagnostics/mcmc_ifac.m
index 3688153f9..7537e62eb 100644
--- a/matlab/convergence_diagnostics/mcmc_ifac.m
+++ b/matlab/convergence_diagnostics/mcmc_ifac.m
@@ -54,7 +54,7 @@ function Ifac = mcmc_ifac(X, Nc)
 % along with Dynare.  If not, see <http://www.gnu.org/licenses/>.
 
 Nc = floor(min(Nc, length(X)/2));
-if mod(Nc,2),
+if mod(Nc,2)
     Nc=Nc-1;
 end
 AcorrXSIM = dyn_autocorr(X(:), Nc);
diff --git a/matlab/convergence_diagnostics/raftery_lewis.m b/matlab/convergence_diagnostics/raftery_lewis.m
index c2a162d87..0b61ca9ba 100644
--- a/matlab/convergence_diagnostics/raftery_lewis.m
+++ b/matlab/convergence_diagnostics/raftery_lewis.m
@@ -85,7 +85,7 @@ for nv = 1:n_vars % big loop over variables
         work = (runs(:,nv) <= quantile(runs(:,nv),q));
     else
         error('Quantile must be between 0 and 1'); 
-    end;
+    end
     
     k_thin_current_var = 1; 
     bic = 1; 
@@ -95,7 +95,7 @@ for nv = 1:n_vars % big loop over variables
         thinned_chain=work(1:k_thin_current_var:n_runs,1); 
         [g2, bic] = first_vs_second_order_MC_test(thinned_chain);
         k_thin_current_var = k_thin_current_var+1;
-    end;
+    end
     
     k_thin_current_var = k_thin_current_var-1; %undo last step
     
@@ -103,7 +103,7 @@ for nv = 1:n_vars % big loop over variables
     transition_matrix = zeros(2,2);
     for i1 = 2:size(thinned_chain,1)
         transition_matrix(thinned_chain(i1-1)+1,thinned_chain(i1)+1) = transition_matrix(thinned_chain(i1-1)+1,thinned_chain(i1)+1)+1;
-    end;
+    end
     alpha = transition_matrix(1,2)/(transition_matrix(1,1)+transition_matrix(1,2)); %prob of going from 1 to 2
     beta = transition_matrix(2,1)/(transition_matrix(2,1)+transition_matrix(2,2));  %prob of going from 2 to 1
 
@@ -114,7 +114,7 @@ for nv = 1:n_vars % big loop over variables
         thinned_chain=work(1:kmind:n_runs,1); 
         [g2, bic] = independence_chain_test(thinned_chain);
         kmind = kmind+1;
-    end;
+    end
     
     m_star  = log((alpha + beta)*epss/max(alpha,beta))/log(abs(1 - alpha - beta)); %equation bottom page 4
     raftery_lewis.M_burn(nv) = fix((m_star+1)*k_thin_current_var);
@@ -124,7 +124,7 @@ for nv = 1:n_vars % big loop over variables
     raftery_lewis.k_ind(nv)  = max(fix(raftery_lewis.I_stat(nv)+1),kmind);
     raftery_lewis.k_thin(nv) = k_thin_current_var;
     raftery_lewis.N_total(nv)= raftery_lewis.M_burn(nv)+raftery_lewis.N_prec(nv);
-end;
+end
 
 end
 
@@ -135,7 +135,7 @@ g2 = 0;
 tran=zeros(2,2,2);
 for t_iter=3:n_obs     % count state transitions
     tran(d(t_iter-2,1)+1,d(t_iter-1,1)+1,d(t_iter,1)+1)=tran(d(t_iter-2,1)+1,d(t_iter-1,1)+1,d(t_iter,1)+1)+1;
-end;
+end
 % Compute the log likelihood ratio statistic for second-order MC vs first-order MC. G2 statistic of Bishop, Fienberg and Holland (1975)
 for ind_1 = 1:2
     for ind_2 = 1:2
@@ -146,9 +146,9 @@ for ind_1 = 1:2
                 focus = tran(ind_1,ind_2,ind_3);
                 g2 = g2 + log(focus/fitted)*focus;
             end
-        end;       % end of for i3
-    end;        % end of for i2
-end;         % end of for i1
+        end       % end of for i3
+    end        % end of for i2
+end         % end of for i1
 g2 = g2*2;
 bic = g2 - log(n_obs-2)*2;
 
@@ -161,7 +161,7 @@ n_obs=size(d,1);
 trans = zeros(2,2);
 for ind_1 = 2:n_obs
     trans(d(ind_1-1)+1,d(ind_1)+1)=trans(d(ind_1-1)+1,d(ind_1)+1)+1;
-end;
+end
 dcm1 = n_obs - 1;  
 g2 = 0;
 % Compute the log likelihood ratio statistic for second-order MC vs first-order MC. G2 statistic of Bishop, Fienberg and Holland (1975)
@@ -171,9 +171,9 @@ for ind_1 = 1:2
             fitted = ((trans(ind_1,1) + trans(ind_1,2))*(trans(1,ind_2) + trans(2,ind_2)))/dcm1; 
             focus = trans(ind_1,ind_2);
             g2 = g2 + log(focus/fitted)*focus;
-        end;
-    end;
-end;
+        end
+    end
+end
 g2 = g2*2; 
 bic = g2 - log(dcm1);
 end
diff --git a/matlab/convertAimCodeToInfo.m b/matlab/convertAimCodeToInfo.m
index 2aaf05be7..159bc694c 100644
--- a/matlab/convertAimCodeToInfo.m
+++ b/matlab/convertAimCodeToInfo.m
@@ -55,7 +55,7 @@ switch aimCode
     info = 161;
   case 62
     info = 162;
-  case 63; 
+  case 63
     info = 163;
   case 64
     info = 164;
diff --git a/matlab/convert_oo_.m b/matlab/convert_oo_.m
index ef5f72280..dc358e87e 100644
--- a/matlab/convert_oo_.m
+++ b/matlab/convert_oo_.m
@@ -63,7 +63,7 @@ else
 end
 
 if strcmp(from_ver, to_ver)
-    return;
+    return
 end
 
 if ver_greater_than(to_ver, from_ver)
diff --git a/matlab/cosn.m b/matlab/cosn.m
index 8fcf7fb79..adee1a45e 100644
--- a/matlab/cosn.m
+++ b/matlab/cosn.m
@@ -1,4 +1,4 @@
-function [co, b, yhat] = cosn(H);
+function [co, b, yhat] = cosn(H)
 
 % function co = cosn(H);
 % computes the cosine of the angle between the H(:,1) and its
@@ -28,11 +28,11 @@ y = H(:,1);
 X = H(:,2:end);
 
 b=(X\y);
-if any(isnan(b)) || any(isinf(b)),
+if any(isnan(b)) || any(isinf(b))
     b=0;
 end
 yhat =  X*b;
-if rank(yhat),
+if rank(yhat)
     co = abs(y'*yhat/sqrt((y'*y)*(yhat'*yhat)));
 else
     co=0;
diff --git a/matlab/csolve.m b/matlab/csolve.m
index 3af47243e..b4d79229b 100644
--- a/matlab/csolve.m
+++ b/matlab/csolve.m
@@ -122,7 +122,7 @@ while ~done
                 factor=factor^.6;
                 shrink=1;
             end
-            if abs(lambda*(1-factor))*dxSize > .1*delta;
+            if abs(lambda*(1-factor))*dxSize > .1*delta
                 lambda = factor*lambda;
             elseif (lambda > 0) && (factor==.6) %i.e., we've only been shrinking
                 lambda=-.3;
@@ -162,7 +162,7 @@ while ~done
     if itct >= itmax
         done=1;
         rc=4;
-    elseif af0<crit;
+    elseif af0<crit
         done=1;
         rc=0;
     end
diff --git a/matlab/discretionary_policy_engine.m b/matlab/discretionary_policy_engine.m
index 154b66426..e365524df 100644
--- a/matlab/discretionary_policy_engine.m
+++ b/matlab/discretionary_policy_engine.m
@@ -239,11 +239,11 @@ function v= SylvesterDoubling (d,g,h,tol,maxit)
 %   to solve the  Sylvester equation v  = d + g v h
 
 v = d;
-for i =1:maxit,
+for i =1:maxit
     vadd = g*v*h;
     v = v+vadd;
     if norm (vadd,1) <= (tol*norm(v,1))
-        break;
+        break
     end
     g = g*g;
     h = h*h;
@@ -295,8 +295,8 @@ temp = [];
 
 %First handle the i = 1 case outside the loop
 
-if i< n,
-    if abs(h(i+1,i)) < tol,
+if i< n
+    if abs(h(i+1,i)) < tol
         v(:,i)= (w - g*h(i,i))\d(:,i);
         i = i+1;
     else
@@ -312,10 +312,10 @@ end
 
 %Handle the rest of the matrix with the possible exception of i=n
 
-while i<n,
+while i<n
     b= i-1;
     temp = [temp g*v(:,size(temp,2)+1:b)]; %#ok<AGROW>
-    if abs(h(i+1,i)) < tol,
+    if abs(h(i+1,i)) < tol
         v(:,i) = (w - g*h(i,i))\(d(:,i) + temp*h(1:b,i));
         i = i+1;
     else
@@ -332,7 +332,7 @@ end
 
 %Handle the i = n case if i=n was not in a 2-2 block
 
-if i==n,
+if i==n
     b = i-1;
     temp = [temp g*v(:,size(temp,2)+1:b)];
     v(:,i) = (w-g*h(i,i))\(d(:,i) + temp*h(1:b,i));
diff --git a/matlab/disp_dr.m b/matlab/disp_dr.m
index a23c8f4be..607ca066d 100644
--- a/matlab/disp_dr.m
+++ b/matlab/disp_dr.m
@@ -36,7 +36,7 @@ else
     k = find(dr.kstate(:,2) <= M_.maximum_lag+1);
     klag = dr.kstate(k,[1 2]);
     k1 = dr.order_var;
-end;
+end
 
 if size(var_list,1) == 0
     var_list = M_.endo_names(1:M_.orig_endo_nbr, :);
diff --git a/matlab/disp_identification.m b/matlab/disp_identification.m
index 5bdb3e8e5..935b73dfc 100644
--- a/matlab/disp_identification.m
+++ b/matlab/disp_identification.m
@@ -19,7 +19,7 @@ function disp_identification(pdraws, idemodel, idemoments, name, advanced)
 
 global options_
 
-if nargin < 5 || isempty(advanced),
+if nargin < 5 || isempty(advanced)
     advanced=0;
 end
 
@@ -84,16 +84,16 @@ end
 
 disp(['  ']),
 
-if any(idemodel.ino),
+if any(idemodel.ino)
     disp('WARNING !!!')
-    if SampleSize>1,
+    if SampleSize>1
         disp(['The rank of H (model) is deficient for ', num2str(length(find(idemodel.ino))),' out of ',int2str(SampleSize),' MC runs!'  ]),
     else
         disp(['The rank of H (model) is deficient!'  ]),
     end
     skipline()
-    for j=1:npar,
-        if any(idemodel.ind0(:,j)==0),
+    for j=1:npar
+        if any(idemodel.ind0(:,j)==0)
             pno = 100*length(find(idemodel.ind0(:,j)==0))/SampleSize;
             if SampleSize>1
                 disp(['    ',name{j},' is not identified in the model for ',num2str(pno),'% of MC runs!' ])
@@ -107,9 +107,9 @@ if any(idemodel.ino),
     jmap_pair=dyn_unvech(1:npairs);
     jstore=[];
     skipline()
-    for j=1:npairs,
+    for j=1:npairs
         iweak = length(find(idemodel.jweak_pair(:,j)));
-        if iweak,
+        if iweak
             [jx,jy]=find(jmap_pair==j);
             jstore=[jstore jx(1) jy(1)];
             if SampleSize > 1
@@ -121,9 +121,9 @@ if any(idemodel.ino),
         
     end
     skipline()
-    for j=1:npar,
+    for j=1:npar
         iweak = length(find(idemodel.jweak(:,j)));
-        if iweak && ~ismember(j,jstore),
+        if iweak && ~ismember(j,jstore)
             %         disp('WARNING !!!')
             %         disp(['Model derivatives of parameter ',name{j},' are multi-collinear (with tol = 1.e-10) for ',num2str(iweak/SampleSize*100),'% of MC runs!' ])
             if SampleSize>1
@@ -157,10 +157,10 @@ if ~any(idemodel.ino) && ~any(any(idemodel.ind0==0))
     skipline()
 end
 
-if any(idemoments.ino),
+if any(idemoments.ino)
     skipline()
     disp('WARNING !!!')
-    if SampleSize > 1,
+    if SampleSize > 1
         disp(['The rank of J (moments) is deficient for ', num2str(length(find(idemoments.ino))),' out of ',int2str(SampleSize),' MC runs!'  ]),
     else
         disp(['The rank of J (moments) is deficient!'  ]),
@@ -173,8 +173,8 @@ if any(idemoments.ino),
 %     ifreq=find(freqno);
     %     disp('MOMENT RANK FAILURE DUE TO COLLINEARITY OF PARAMETERS:');
     skipline()
-    for j=1:npar,
-        if any(idemoments.ind0(:,j)==0),
+    for j=1:npar
+        if any(idemoments.ind0(:,j)==0)
             pno = 100*length(find(idemoments.ind0(:,j)==0))/SampleSize;
             if SampleSize > 1
                 disp(['    ',name{j},' is not identified by J moments for ',num2str(pno),'% of MC runs!' ])
@@ -188,9 +188,9 @@ if any(idemoments.ino),
     npairs=size(idemoments.jweak_pair,2);
     jmap_pair=dyn_unvech(1:npairs);
     jstore=[];
-    for j=1:npairs,
+    for j=1:npairs
         iweak = length(find(idemoments.jweak_pair(:,j)));
-        if iweak,
+        if iweak
             [jx,jy]=find(jmap_pair==j);
             jstore=[jstore'  jx(1) jy(1)]';
             if SampleSize > 1
@@ -202,12 +202,12 @@ if any(idemoments.ino),
         
     end
     skipline()
-    for j=1:npar,
+    for j=1:npar
         iweak = length(find(idemoments.jweak(:,j)));
-        if iweak && ~ismember(j,jstore),
+        if iweak && ~ismember(j,jstore)
             %             disp('WARNING !!!')
             %             disp(['Moment derivatives of parameter ',name{j},' are multi-collinear (with tol = 1.e-10) for ',num2str(iweak/SampleSize*100),'% of MC runs!' ])
-            if SampleSize > 1,
+            if SampleSize > 1
                 disp([name{j},' is collinear w.r.t. all other params ',num2str(iweak/SampleSize*100),'% of MC runs!' ])
             else
                 disp([name{j},' is collinear w.r.t. all other params!' ])
@@ -266,19 +266,19 @@ end
 % disp(' ')
 
 % identificaton patterns
-if SampleSize==1 && advanced,
+if SampleSize==1 && advanced
     skipline()
     disp('Press ENTER to print advanced diagnostics'), pause(5),
-    for  j=1:size(idemoments.cosnJ,2),
+    for  j=1:size(idemoments.cosnJ,2)
         pax=NaN(npar,npar);
         fprintf('\n')
         disp(['Collinearity patterns with ', int2str(j) ,' parameter(s)'])
         fprintf('%-15s [%-*s] %10s\n','Parameter',(15+1)*j,' Expl. params ','cosn')
-        for i=1:npar,
+        for i=1:npar
             namx='';
-            for in=1:j,
+            for in=1:j
                 dumpindx = idemoments.pars{i,j}(in);
-                if isnan(dumpindx),
+                if isnan(dumpindx)
                     namx=[namx ' ' sprintf('%-15s','--')];
                 else
                     namx=[namx ' ' sprintf('%-15s',name{dumpindx})];
diff --git a/matlab/disp_th_moments.m b/matlab/disp_th_moments.m
index 45d217611..b699a5156 100644
--- a/matlab/disp_th_moments.m
+++ b/matlab/disp_th_moments.m
@@ -127,7 +127,7 @@ if options_.nocorr == 0 && size(stationary_vars, 1) > 0
     if options_.contemporaneous_correlation 
         oo_.contemporaneous_correlation = corr;
     end
-    if ~options_.noprint,
+    if ~options_.noprint
         skipline()
         if options_.order == 2
             title='APPROXIMATED MATRIX OF CORRELATIONS';            
@@ -153,7 +153,7 @@ if options_.ar > 0 && size(stationary_vars, 1) > 0
         oo_.autocorr{i} = oo_.gamma_y{i+1};
         z(:,i) = diag(oo_.gamma_y{i+1}(i1,i1));
     end
-    if ~options_.noprint,      
+    if ~options_.noprint
         skipline()    
         if options_.order == 2
             title='APPROXIMATED COEFFICIENTS OF AUTOCORRELATION';            
diff --git a/matlab/display_problematic_vars_Jacobian.m b/matlab/display_problematic_vars_Jacobian.m
index a4278208b..c302df213 100644
--- a/matlab/display_problematic_vars_Jacobian.m
+++ b/matlab/display_problematic_vars_Jacobian.m
@@ -50,7 +50,7 @@ if strcmp(type,'dynamic')
             type_string='';
         elseif var_row==1
             type_string='lag of';
-        elseif var_row==3;
+        elseif var_row==3
             type_string='lead of';
         end
         if problemcol(ii)<=max(max(M_.lead_lag_incidence)) && var_index<=M_.orig_endo_nbr
diff --git a/matlab/distributions/inverse_gamma_specification.m b/matlab/distributions/inverse_gamma_specification.m
index c7f02a194..558fdbd7f 100644
--- a/matlab/distributions/inverse_gamma_specification.m
+++ b/matlab/distributions/inverse_gamma_specification.m
@@ -85,10 +85,10 @@ nu = [];
 sigma = sqrt(sigma2);
 mu2 = mu*mu;
 
-if type == 2;       % Inverse Gamma 2
+if type == 2       % Inverse Gamma 2
     nu   = 2*(2+mu2/sigma2);
     s    = 2*mu*(1+mu2/sigma2);
-elseif type == 1;   % Inverse Gamma 1
+elseif type == 1   % Inverse Gamma 1
     if sigma2 < Inf
         nu = sqrt(2*(2+mu2/sigma2));
         if use_fzero_flag
diff --git a/matlab/distributions/multivariate_normal_pdf.m b/matlab/distributions/multivariate_normal_pdf.m
index 29feabaf6..c7dd73871 100644
--- a/matlab/distributions/multivariate_normal_pdf.m
+++ b/matlab/distributions/multivariate_normal_pdf.m
@@ -1,4 +1,4 @@
-function density = multivariate_normal_pdf(X,Mean,Sigma_upper_chol,n);
+function density = multivariate_normal_pdf(X,Mean,Sigma_upper_chol,n)
 % Evaluates the density of a multivariate gaussian, with expectation Mean
 % and variance Sigma_upper_chol'*Sigma_upper_chol, at X.
 % 
diff --git a/matlab/distributions/multivariate_student_pdf.m b/matlab/distributions/multivariate_student_pdf.m
index 3f498c673..54dadfc68 100644
--- a/matlab/distributions/multivariate_student_pdf.m
+++ b/matlab/distributions/multivariate_student_pdf.m
@@ -1,4 +1,4 @@
-function density = multivariate_student_pdf(X,Mean,Sigma_upper_chol,df);
+function density = multivariate_student_pdf(X,Mean,Sigma_upper_chol,df)
 % Evaluates the density of a multivariate student, with expectation Mean,
 % variance Sigma_upper_chol'*Sigma_upper_chol and degrees of freedom df, at X.
 %
diff --git a/matlab/dr_block.m b/matlab/dr_block.m
index 47c20add2..b1e7f2296 100644
--- a/matlab/dr_block.m
+++ b/matlab/dr_block.m
@@ -69,13 +69,13 @@ if (isfield(M_,'block_structure'))
 else
     data = M_;
     Size = 1;
-end;
+end
 if (options_.bytecode)
     [chck, zz, data]= bytecode('dynamic','evaluate', z, zx, M_.params, dr.ys, 1, data);
 else
     [r, data] = feval([M_.fname '_dynamic'], options_, M_, oo_, z', zx, M_.params, dr.ys, M_.maximum_lag+1, data);
     chck = 0;
-end;
+end
 mexErrCheck('bytecode', chck);
 dr.full_rank = 1;
 dr.eigval = [];
@@ -90,7 +90,7 @@ n_sv = size(dr.state_var, 2);
 dr.ghx = zeros(M_.endo_nbr, length(dr.state_var));
 dr.exo_var = 1:M_.exo_nbr;
 dr.ghu = zeros(M_.endo_nbr, M_.exo_nbr);
-for i = 1:Size;
+for i = 1:Size
     ghx = [];
     indexi_0 = 0;
     if (verbose)
@@ -98,7 +98,7 @@ for i = 1:Size;
         disp(['Block ' int2str(i)]);
         disp('-----------');
         data(i)
-    end;
+    end
     n_pred = data(i).n_backward;
     n_fwrd = data(i).n_forward;
     n_both = data(i).n_mixed;
@@ -118,7 +118,7 @@ for i = 1:Size;
         disp(jacob);
         disp('lead_lag_incidence');
         disp(lead_lag_incidence);
-    end;
+    end
     maximum_lag = data(i).maximum_endo_lag;
     maximum_lead = data(i).maximum_endo_lead;
     n = n_dynamic + n_static;
@@ -127,11 +127,11 @@ for i = 1:Size;
     if task ~= 1
         if block_type == 2 || block_type == 4 || block_type == 7 
             block_type = 8;
-        end;
-    end;
+        end
+    end
     if maximum_lag > 0 && (n_pred > 0  || n_both > 0) && block_type ~= 1 
         indexi_0 = min(lead_lag_incidence(2,:));
-    end;
+    end
     switch block_type
       case 1
       %% ------------------------------------------------------------------
@@ -153,7 +153,7 @@ for i = 1:Size;
             if (maximum_lag > 0 && n_pred > 0)
                 [indx_r, tmp1, indx_r_v]  = find(M_.block_structure.block(i).lead_lag_incidence(1,:));
                 ghx = - B \ jacob(:,indx_r_v);
-            end;
+            end
             if other_endo_nbr
                 fx = data(i).g1_o;
                 % retrieves the derivatives with respect to endogenous
@@ -178,7 +178,7 @@ for i = 1:Size;
                
                 ghx_other = - B \ (fx_t * l_x + (fx_tp1 * l_x * l_x_sv) + fx_tm1 * selector_tm1);
                 dr.ghx(endo, :) = dr.ghx(endo, :) + ghx_other;
-            end;
+            end
             
             if exo_nbr
                 fu = data(i).g1_x;
@@ -194,7 +194,7 @@ for i = 1:Size;
                     fu_complet = zeros(n, M_.exo_nbr);
                     fu_complet(:,data(i).exogenous) = fu;
                     ghu = - B \ fu_complet;
-                end;
+                end
             else
                 exo = dr.exo_var;
                 if other_endo_nbr > 0
@@ -229,7 +229,7 @@ for i = 1:Size;
                 indx_r = find(M_.block_structure.block(i).lead_lag_incidence(3,:));
                 indx_c = M_.block_structure.block(i).lead_lag_incidence(3,indx_r);
                 ghx = - inv(jacob(indx_r, indx_c));
-            end;
+            end
             ghu =  - inv(jacob(indx_r, indx_c)) * data(i).g1_x;
         end
       case 3
@@ -241,7 +241,7 @@ for i = 1:Size;
         else
             data(i).eigval = [];
             data(i).rank = 0;
-        end;
+        end
         dr.eigval = [dr.eigval ; data(i).eigval];
         %First order approximation
         if task ~= 1
@@ -249,7 +249,7 @@ for i = 1:Size;
                  ghx = - jacob(1 , 1 : n_pred) / jacob(1 , n_pred + n_static + 1 : n_pred + n_static + n_pred + n_both);
             else
                  ghx = 0;
-            end;
+            end
             if other_endo_nbr
                 fx = data(i).g1_o;
                 % retrieves the derivatives with respect to endogenous
@@ -274,7 +274,7 @@ for i = 1:Size;
                 ghx_other = - (fx_t * l_x + (fx_tp1 * l_x * l_x_sv) + fx_tm1 * selector_tm1) / jacob(1 , n_pred + 1 : n_pred + n_static + n_pred + n_both);
                 dr.ghx(endo, :) = dr.ghx(endo, :) + ghx_other;
 
-            end;
+            end
             if exo_nbr
                 fu = data(i).g1_x;
                 if other_endo_nbr > 0
@@ -287,7 +287,7 @@ for i = 1:Size;
                     exo = dr.exo_var;
                 else
                     ghu = - fu  / jacob(1 , n_pred + 1 : n_pred + n_static + n_pred + n_both);
-                end;
+                end
             else
                  if other_endo_nbr > 0
                      l_u_sv = dr.ghu(dr.state_var,:);
@@ -311,7 +311,7 @@ for i = 1:Size;
             data(i).eigval = [];
             data(i).rank = 0;
             full_rank = 1;
-        end;
+        end
         dr.full_rank = dr.full_rank && full_rank;
         dr.eigval = [dr.eigval ; data(i).eigval];
       case 6
@@ -322,7 +322,7 @@ for i = 1:Size;
                         + n_pred + n_both) \ jacob(: , 1 : n_pred);
         else
             ghx = 0;
-        end;
+        end
         if maximum_lag > 0 && n_pred > 0
             data(i).eigval = -eig(ghx(n_static+1:end,:));
             data(i).rank = 0;
@@ -331,7 +331,7 @@ for i = 1:Size;
             data(i).eigval = [];
             data(i).rank = 0;
             full_rank = 1;
-        end;
+        end
         dr.eigval = [dr.eigval ; data(i).eigval];
         dr.full_rank = dr.full_rank && full_rank;
         if task ~= 1
@@ -358,7 +358,7 @@ for i = 1:Size;
                 selector_tm1 = M_.block_structure.block(i).tm1;
                 ghx_other = - (fx_t * l_x + (fx_tp1 * l_x * l_x_sv) + fx_tm1 * selector_tm1) / jacob(: , n_pred + 1 : n_pred + n_static + n_pred + n_both);
                 dr.ghx(endo, :) = dr.ghx(endo, :) + ghx_other;
-            end;
+            end
             if exo_nbr
                 fu = data(i).g1_x;
                 if other_endo_nbr > 0
@@ -371,7 +371,7 @@ for i = 1:Size;
                     exo = dr.exo_var;
                 else
                     ghu = - fu  / jacob(: , n_pred + 1 : n_pred + n_static + n_pred + n_both);
-                end;
+                end
             else
                  if other_endo_nbr > 0
                      l_u_sv = dr.ghu(dr.state_var,:);
@@ -397,7 +397,7 @@ for i = 1:Size;
             data(i).eigval = [];
             data(i).rank = 0;
             full_rank = 1;
-        end;
+        end
         dr.full_rank = dr.full_rank && full_rank;
         dr.eigval = [dr.eigval ; data(i).eigval];
       case {5,8}
@@ -413,7 +413,7 @@ for i = 1:Size;
             aa = Q'*jacob;
         else
             aa = jacob;
-        end;
+        end
         index_0m = (n_static+1:n_static+n_pred) + indexi_0 - 1;
         index_0p = (n_static+n_pred+1:n) + indexi_0 - 1;
         index_m = 1:(n_pred+n_both);
@@ -445,7 +445,7 @@ for i = 1:Size;
             if (verbose)
                 disp('eigval');
                 disp(data(i).eigval);
-            end;
+            end
             if info1
                 if info1 == -30
                     % one eigenvalue is close to 0/0
@@ -468,7 +468,7 @@ for i = 1:Size;
                 disp(['sum eigval > 1 = ' int2str(sum(abs(data(i).eigval) > 1.)) ' nyf=' int2str(nyf) ' and dr.rank=' int2str(data(i).rank)]);
                 disp(['data(' int2str(i) ').eigval']);
                 disp(data(i).eigval);
-            end;
+            end
 
             %First order approximation
             if task ~= 1
@@ -487,7 +487,7 @@ for i = 1:Size;
                         if nba > nyf
                             temp = sorted_roots(nd-nba+1:nd-nyf)-1-options_.qz_criterium;
                             info(1) = 3;
-                        elseif nba < nyf;
+                        elseif nba < nyf
                             temp = sorted_roots(nd-nyf+1:nd-nba)-1-options_.qz_criterium;
                             info(1) = 4;
                         end
@@ -507,7 +507,7 @@ for i = 1:Size;
                     % condest() fails on a scalar under Octave
                     info(1) = 5;
                     info(2) = condest(Z21);
-                    return;
+                    return
                 else
                     %gx = -inv(Z22) * Z21;
                     gx = - Z22 \ Z21;
@@ -520,8 +520,8 @@ for i = 1:Size;
                 k2 = 1:(n_fwrd+n_both);
 
                 ghx = [hx(k1,:); gx(k2(n_both+1:end),:)];
-            end;
-        end;
+            end
+        end
         
         if  task~= 1 
             %lead variables actually present in the model
@@ -533,7 +533,7 @@ for i = 1:Size;
                 B_static = B(:,1:n_static);  % submatrix containing the derivatives w.r. to static variables
             else
                 B_static = [];
-            end;
+            end
             %static variables, backward variable, mixed variables and forward variables
             B_pred = B(:,n_static+1:n_static+n_pred+n_both);
             B_fyd = B(:,n_static+n_pred+n_both+1:end);
@@ -549,7 +549,7 @@ for i = 1:Size;
                 temp = b10\(temp-b11*ghx);
                 ghx = [temp; ghx];
                 temp = [];
-            end;
+            end
             
             A_ = real([B_static C(:,j3)*gx+B_pred B_fyd]); % The state_variable of the block are located at [B_pred B_both]
             
@@ -558,7 +558,7 @@ for i = 1:Size;
                      fx = Q' * data(i).g1_o;
                 else
                     fx = data(i).g1_o;
-                end;
+                end
                 % retrieves the derivatives with respect to endogenous
                 % variable belonging to previous blocks
                 fx_tm1 = zeros(n,other_endo_nbr);
@@ -592,21 +592,21 @@ for i = 1:Size;
                     ghx_other = gensylv_fp(A_, B_, C_, D_, i, options_.sylvester_fixed_point_tol);
                 else 
                     [err, ghx_other] = gensylv(1, A_, B_, C_, -D_);
-                end;
+                end
                 if options_.aim_solver ~= 1 && options_.use_qzdiv
                    % Necessary when using Sims' routines for QZ
                    ghx_other = real(ghx_other);
                 end
                 
                 dr.ghx(endo, :) = dr.ghx(endo, :) + ghx_other;
-            end;
+            end
 
             if exo_nbr
                 if n_static > 0
                     fu = Q' * data(i).g1_x;
                 else
                     fu = data(i).g1_x;
-                end;
+                end
 
                 if other_endo_nbr > 0
                     l_u_sv = dr.ghu(dr.state_var,:);
@@ -621,7 +621,7 @@ for i = 1:Size;
                     exo = dr.exo_var;
                 else
                     ghu = - A_ \ fu;
-                end;
+                end
             else
                 if other_endo_nbr > 0
                     l_u_sv = dr.ghu(dr.state_var,:);
@@ -633,7 +633,7 @@ for i = 1:Size;
                     exo = dr.exo_var;
                 else
                     ghu = [];
-                end;
+                end
             end
 
 
@@ -671,7 +671,7 @@ for i = 1:Size;
 %                 end
             end
         end
-    end;
+    end
     if task ~=1
         if (maximum_lag > 0 && (n_pred > 0 || n_both > 0))
             sorted_col_dr_ghx = M_.block_structure.block(i).sorted_col_dr_ghx;
@@ -680,27 +680,27 @@ for i = 1:Size;
             data(i).pol.i_ghx = sorted_col_dr_ghx;
         else
             data(i).pol.i_ghx = [];
-        end;
+        end
         data(i).ghu = ghu;
         dr.ghu(endo, exo) = ghu;
         data(i).pol.i_ghu = exo;
-    end;
+    end
     
    if (verbose)
         disp('dr.ghx');
         dr.ghx
         disp('dr.ghu');
         dr.ghu
-   end; 
+   end 
    
-end;
+end
 M_.block_structure.block = data ;
 if (verbose)
         disp('dr.ghx');
         disp(real(dr.ghx));
         disp('dr.ghu');
         disp(real(dr.ghu));
-end; 
+end 
 if (task == 1)
-    return;
-end;
+    return
+end
diff --git a/matlab/draw_prior_density.m b/matlab/draw_prior_density.m
index 23479b404..5f4ce9b95 100644
--- a/matlab/draw_prior_density.m
+++ b/matlab/draw_prior_density.m
@@ -1,4 +1,4 @@
-function [x,f,abscissa,dens,binf,bsup] = draw_prior_density(indx,bayestopt_);
+function [x,f,abscissa,dens,binf,bsup] = draw_prior_density(indx,bayestopt_)
 % Computes values of prior densities at many points (before plotting)
 %
 % INPUTS
diff --git a/matlab/dsge_likelihood.m b/matlab/dsge_likelihood.m
index 30bb87b5f..fc5e64295 100644
--- a/matlab/dsge_likelihood.m
+++ b/matlab/dsge_likelihood.m
@@ -167,11 +167,11 @@ if analytic_derivation && DynareOptions.loglinear
     error('The analytic_derivation and loglinear options are not compatible')
 end
 
-if nargout==1,
+if nargout==1
     analytic_derivation=0;
 end
 
-if analytic_derivation,
+if analytic_derivation
     kron_flag=DynareOptions.analytic_derivation_mode;
 end
 
@@ -186,7 +186,7 @@ if isestimation(DynareOptions) && ~isequal(DynareOptions.mode_compute,1) && any(
     exit_flag = 0;
     info(1) = 41;
     info(4)= sum((BoundsInfo.lb(k)-xparam1(k)).^2);
-    if analytic_derivation,
+    if analytic_derivation
         DLIK=ones(length(xparam1),1);
     end
     return
@@ -199,7 +199,7 @@ if isestimation(DynareOptions) && ~isequal(DynareOptions.mode_compute,1) && any(
     exit_flag = 0;
     info(1) = 42;
     info(4)= sum((xparam1(k)-BoundsInfo.ub(k)).^2);
-    if analytic_derivation,
+    if analytic_derivation
         DLIK=ones(length(xparam1),1);
     end
     return
@@ -274,35 +274,32 @@ if info(1)
         fval = Inf;
         info(4) = info(2);
         exit_flag = 0;
-        if analytic_derivation,
+        if analytic_derivation
             DLIK=ones(length(xparam1),1);
         end
-        
         return
     else
         fval = Inf;
         info(4) = 0.1;
         exit_flag = 0;
-        if analytic_derivation,
+        if analytic_derivation
             DLIK=ones(length(xparam1),1);
         end
-        
         return
     end
 end
 
 % check endogenous prior restrictions
 info=endogenous_prior_restrictions(T,R,Model,DynareOptions,DynareResults);
-if info(1),
+if info(1)
     fval = Inf;
     info(4)=info(2);
     exit_flag = 0;
-    if analytic_derivation,
+    if analytic_derivation
         DLIK=ones(length(xparam1),1);
     end
     return
 end
-%
 
 % Define a vector of indices for the observed variables. Is this really usefull?...
 BayesInfo.mf = BayesInfo.mf1;
@@ -446,7 +443,7 @@ switch DynareOptions.lik_init
                                                         T,R,Q,H1,Z,mmm,pp,rr);
         diffuse_periods = size(dlik,1);
     end
-    if isnan(dLIK),
+    if isnan(dLIK)
         fval = Inf;
         info(1) = 45;
         info(4) = 0.1;
@@ -495,20 +492,19 @@ switch DynareOptions.lik_init
     error('dsge_likelihood:: Unknown initialization approach for the Kalman filter!')
 end
 
-if analytic_derivation,
+if analytic_derivation
     offset = EstimatedParameters.nvx;
     offset = offset+EstimatedParameters.nvn;
     offset = offset+EstimatedParameters.ncx;
     offset = offset+EstimatedParameters.ncn;
-
     no_DLIK = 0;
     full_Hess = analytic_derivation==2;
     asy_Hess = analytic_derivation==-2;
     outer_product_gradient = analytic_derivation==-1;
-    if asy_Hess,
+    if asy_Hess
         analytic_derivation=1;
     end
-    if outer_product_gradient,
+    if outer_product_gradient
         analytic_derivation=1;
     end
     DLIK = [];
@@ -526,8 +522,7 @@ if analytic_derivation,
         else
             indparam=[];
         end
-
-        if full_Hess,
+        if full_Hess
             [dum, DT, DOm, DYss, dum2, D2T, D2Om, D2Yss] = getH(A, B, EstimatedParameters, Model,DynareResults,DynareOptions,kron_flag,indparam,indexo,iv);
             clear dum dum2;
         else
@@ -537,15 +532,15 @@ if analytic_derivation,
         DT = derivatives_info.DT(iv,iv,:);
         DOm = derivatives_info.DOm(iv,iv,:);
         DYss = derivatives_info.DYss(iv,:);
-        if isfield(derivatives_info,'full_Hess'),
+        if isfield(derivatives_info,'full_Hess')
             full_Hess = derivatives_info.full_Hess;
         end
-        if full_Hess,
+        if full_Hess
         D2T = derivatives_info.D2T;
         D2Om = derivatives_info.D2Om;
         D2Yss = derivatives_info.D2Yss;
         end
-        if isfield(derivatives_info,'no_DLIK'),
+        if isfield(derivatives_info,'no_DLIK')
             no_DLIK = derivatives_info.no_DLIK;
         end
         clear('derivatives_info');
@@ -554,8 +549,8 @@ if analytic_derivation,
     DH=zeros([length(H),length(H),length(xparam1)]);
     DQ=zeros([size(Q),length(xparam1)]);
     DP=zeros([size(T),length(xparam1)]);
-    if full_Hess,
-        for j=1:size(D2Yss,1),
+    if full_Hess
+        for j=1:size(D2Yss,1)
         tmp(j,:,:) = blkdiag(zeros(offset,offset), squeeze(D2Yss(j,:,:)));
         end
         D2Yss = tmp;
@@ -563,7 +558,7 @@ if analytic_derivation,
         D2P=sparse(size(D2Om,1),size(D2Om,2)); %zeros([size(T),length(xparam1),length(xparam1)]);
         jcount=0;
     end
-    if DynareOptions.lik_init==1,
+    if DynareOptions.lik_init==1
     for i=1:EstimatedParameters.nvx
         k =EstimatedParameters.var_exo(i,1);
         DQ(k,k,i) = 2*sqrt(Q(k,k));
@@ -572,7 +567,7 @@ if analytic_derivation,
 %         dum(kk) = 0;
         DP(:,:,i)=dum;
         if full_Hess
-        for j=1:i,
+        for j=1:i
             jcount=jcount+1;
             dum =  lyapunov_symm(T,dyn_unvech(D2Om(:,jcount)),DynareOptions.lyapunov_fixed_point_tol,DynareOptions.qz_criterium,DynareOptions.lyapunov_complex_threshold,[],DynareOptions.debug);
 %             kk = (abs(dum) < 1e-12);
@@ -592,7 +587,7 @@ if analytic_derivation,
         end
     end
     offset = offset + EstimatedParameters.nvn;
-    if DynareOptions.lik_init==1,
+    if DynareOptions.lik_init==1
     for j=1:EstimatedParameters.np
         dum =  lyapunov_symm(T,DT(:,:,j+offset)*Pstar*T'+T*Pstar*DT(:,:,j+offset)'+DOm(:,:,j+offset),DynareOptions.lyapunov_fixed_point_tol,DynareOptions.qz_criterium,DynareOptions.lyapunov_complex_threshold,[],DynareOptions.debug);
 %         kk = find(abs(dum) < 1e-12);
@@ -601,7 +596,7 @@ if analytic_derivation,
         if full_Hess
         DTj = DT(:,:,j+offset);
         DPj = dum;
-        for i=1:j+offset,
+        for i=1:j+offset
             jcount=jcount+1;
             DTi = DT(:,:,i);
             DPi = DP(:,:,i);
@@ -616,11 +611,11 @@ if analytic_derivation,
         end
     end
     end
-    if analytic_derivation==1,
+    if analytic_derivation==1
         analytic_deriv_info={analytic_derivation,DT,DYss,DOm,DH,DP,asy_Hess};
     else
         analytic_deriv_info={analytic_derivation,DT,DYss,DOm,DH,DP,D2T,D2Yss,D2Om,D2H,D2P};
-        clear DT DYss DOm DP D2T D2Yss D2Om D2H D2P,
+        clear DT DYss DOm DP D2T D2Yss D2Om D2H D2P
     end
 else
     analytic_deriv_info={0};
@@ -648,7 +643,6 @@ if ((kalman_algo==1) || (kalman_algo==3))% Multivariate Kalman Filter
                 exit_flag = 0; 
                 return
             end
-
             [LIK,lik] = kalman_filter_fast(Y,diffuse_periods+1,size(Y,2), ...
                                            a,Pstar, ...
                                            kalman_tol, riccati_tol, ...
@@ -677,7 +671,7 @@ if ((kalman_algo==1) || (kalman_algo==3))% Multivariate Kalman Filter
                                                            T,Q,R,H,Z,mm,pp,rr,Zflag,diffuse_periods);
         end
     end
-    if analytic_derivation,
+    if analytic_derivation
         LIK1=LIK;
         LIK=LIK1{1};
         lik1=lik;
@@ -701,8 +695,8 @@ if ((kalman_algo==1) || (kalman_algo==3))% Multivariate Kalman Filter
     else
         if DynareOptions.lik_init==3
             LIK = LIK + dLIK;
-            if analytic_derivation==0 && nargout>3,
-                if ~singular_diffuse_filter,
+            if analytic_derivation==0 && nargout>3
+                if ~singular_diffuse_filter
                     lik = [dlik; lik];
                 else
                     lik = [sum(dlik,2); lik];
@@ -718,7 +712,7 @@ if (kalman_algo==2) || (kalman_algo==4)
     if isequal(H,0)
         H1 = zeros(pp,1);
         mmm = mm;
-        if analytic_derivation,
+        if analytic_derivation
             DH = zeros(pp,length(xparam1));
         end
     else
@@ -726,8 +720,8 @@ if (kalman_algo==2) || (kalman_algo==4)
             H1 = diag(H);
             mmm = mm;
             clear('tmp')
-            if analytic_derivation,
-                for j=1:pp,
+            if analytic_derivation
+                for j=1:pp
                     tmp(j,:)=DH(j,j,:);
                 end
                 DH=tmp;
@@ -756,17 +750,16 @@ if (kalman_algo==2) || (kalman_algo==4)
             end
         end
     end
-    if analytic_derivation,
+    if analytic_derivation
         analytic_deriv_info{5}=DH;
     end
-
     [LIK, lik] = univariate_kalman_filter(DatasetInfo.missing.aindex,DatasetInfo.missing.number_of_observations,DatasetInfo.missing.no_more_missing_observations,Y,diffuse_periods+1,size(Y,2), ...
                                           a,Pstar, ...
                                           DynareOptions.kalman_tol, ...
                                           DynareOptions.riccati_tol, ...
                                           DynareOptions.presample, ...
                                           T,Q,R,H1,Z,mmm,pp,rr,Zflag,diffuse_periods,analytic_deriv_info{:});
-    if analytic_derivation,
+    if analytic_derivation
         LIK1=LIK;
         LIK=LIK1{1};
         lik1=lik;
@@ -774,7 +767,7 @@ if (kalman_algo==2) || (kalman_algo==4)
     end
     if DynareOptions.lik_init==3
         LIK = LIK+dLIK;
-        if analytic_derivation==0 && nargout>3,
+        if analytic_derivation==0 && nargout>3
             lik = [dlik; lik];
         end
     end
@@ -785,12 +778,12 @@ if analytic_derivation
         DLIK = LIK1{2};
         %                 [DLIK] = score(T,R,Q,H,Pstar,Y,DT,DYss,DOm,DH,DP,start,Z,kalman_tol,riccati_tol);
     end
-    if full_Hess ,
+    if full_Hess
         Hess = -LIK1{3};
         %                     [Hess, DLL] = get_Hessian(T,R,Q,H,Pstar,Y,DT,DYss,DOm,DH,DP,D2T,D2Yss,D2Om,D2H,D2P,start,Z,kalman_tol,riccati_tol);
         %                     Hess0 = getHessian(Y,T,DT,D2T, R*Q*transpose(R),DOm,D2Om,Z,DYss,D2Yss);
     end
-    if asy_Hess,
+    if asy_Hess
         %         if ~((kalman_algo==2) || (kalman_algo==4)),
         %             [Hess] = AHessian(T,R,Q,H,Pstar,Y,DT,DYss,DOm,DH,DP,start,Z,kalman_tol,riccati_tol);
         %         else
@@ -829,7 +822,7 @@ likelihood = LIK;
 % 5. Adds prior if necessary
 % ------------------------------------------------------------------------------
 if analytic_derivation
-    if full_Hess,
+    if full_Hess
         [lnprior, dlnprior, d2lnprior] = priordens(xparam1,BayesInfo.pshape,BayesInfo.p6,BayesInfo.p7,BayesInfo.p3,BayesInfo.p4);
         Hess = Hess - d2lnprior;
     else
@@ -838,7 +831,7 @@ if analytic_derivation
     if no_DLIK==0
         DLIK = DLIK - dlnprior';
     end
-    if outer_product_gradient,
+    if outer_product_gradient
         dlik = lik1{2};
         dlik=[- dlnprior; dlik(start:end,:)];
         Hess = dlik'*dlik;
@@ -884,7 +877,7 @@ if ~DynareOptions.kalman.keep_kalman_algo_if_singularity_is_detected
     DynareOptions.kalman_algo = kalman_algo;
 end
 
-if analytic_derivation==0 && nargout>3,
+if analytic_derivation==0 && nargout>3
     lik=lik(start:end,:);
     DLIK=[-lnprior; lik(:)];
 end
diff --git a/matlab/dsge_simulated_theoretical_correlation.m b/matlab/dsge_simulated_theoretical_correlation.m
index 265336dbb..eded5cc80 100644
--- a/matlab/dsge_simulated_theoretical_correlation.m
+++ b/matlab/dsge_simulated_theoretical_correlation.m
@@ -126,7 +126,7 @@ for file = 1:NumberOfDrawsFiles
                 Correlation_array = zeros(NumberOfLinesInTheLastCorrFile,nvar,nvar,nar);
                 NumberOfCorrLines = NumberOfLinesInTheLastCorrFile;
                 CorrFileNumber = CorrFileNumber - 1;
-            elseif test<0;
+            elseif test<0
                 Correlation_array = zeros(MaXNumberOfCorrLines,nvar,nvar,nar);
             else
                 clear('Correlation_array');
diff --git a/matlab/dsge_simulated_theoretical_variance_decomposition.m b/matlab/dsge_simulated_theoretical_variance_decomposition.m
index a8ddadec6..491f4f148 100644
--- a/matlab/dsge_simulated_theoretical_variance_decomposition.m
+++ b/matlab/dsge_simulated_theoretical_variance_decomposition.m
@@ -150,7 +150,7 @@ for file = 1:NumberOfDrawsFiles
             if ~test% Prepare the last round...
                 Decomposition_array = zeros(NumberOfLinesInTheLastDecompFile,nvar*nexo);
                 NumberOfDecompLines = NumberOfLinesInTheLastDecompFile;
-            elseif test<0;
+            elseif test<0
                 Decomposition_array = zeros(MaXNumberOfDecompLines,nvar*nexo);
             else
                 clear('Decomposition_array');
diff --git a/matlab/dsge_var_likelihood.m b/matlab/dsge_var_likelihood.m
index 94f8e21ac..d67dcfb84 100644
--- a/matlab/dsge_var_likelihood.m
+++ b/matlab/dsge_var_likelihood.m
@@ -108,7 +108,7 @@ if isestimation(DynareOptions) && DynareOptions.mode_compute ~= 1 && any(xparam1
     exit_flag = 0;
     info(1) = 41;
     info(4)= sum((BoundsInfo.lb(k)-xparam1(k)).^2);
-    return;
+    return
 end
 
 % Return, with endogenous penalty, if some dsge-parameters are greater than the upper bound of the prior domain.
@@ -118,7 +118,7 @@ if isestimation(DynareOptions) && DynareOptions.mode_compute ~= 1 && any(xparam1
     exit_flag = 0;
     info(1) = 42;
     info(4) = sum((xparam1(k)-BoundsInfo.ub(k)).^2);
-    return;
+    return
 end
 
 % Get the variance of each structural innovation.
@@ -137,7 +137,7 @@ Model.Sigma_e = Q;
 dsge_prior_weight = Model.params(dsge_prior_weight_idx);
 
 % Is the dsge prior proper?
-if dsge_prior_weight<(NumberOfParameters+NumberOfObservedVariables)/NumberOfObservations;
+if dsge_prior_weight<(NumberOfParameters+NumberOfObservedVariables)/NumberOfObservations
     fval = Inf;
     exit_flag = 0;
     info(1) = 51;
@@ -239,7 +239,7 @@ if ~SIGMA_u_star_is_positive_definite
     info(1) = 53;
     info(4) = penalty;
     exit_flag = 0;
-    return;
+    return
 end
 
 if ~isinf(dsge_prior_weight)% Evaluation of the likelihood of the dsge-var model when the dsge prior weight is finite.
@@ -254,7 +254,7 @@ if ~isinf(dsge_prior_weight)% Evaluation of the likelihood of the dsge-var model
         info(1) = 52;
         info(4) = penalty;
         exit_flag = 0;
-        return;
+        return
     end
     SIGMA_u_tilde = SIGMA_u_tilde / (NumberOfObservations*(1+dsge_prior_weight));   %prefactor of formula (29), DS (2004)
     PHI_tilde = tmp2*tmp1';                                                   %formula (28), DS (2004)
diff --git a/matlab/dyn_autocorr.m b/matlab/dyn_autocorr.m
index 43534d7be..e4565cf45 100644
--- a/matlab/dyn_autocorr.m
+++ b/matlab/dyn_autocorr.m
@@ -35,6 +35,6 @@ acf = NaN(ar+1,1);
 acf(1)=1;
 m = mean(y);
 sd = std(y,1);
-for i=1:ar,
+for i=1:ar
     acf(i+1) = (y(i+1:end)-m)'*(y(1:end-i)-m)./((size(y,1))*sd^2);
 end
diff --git a/matlab/dyn_first_order_solver.m b/matlab/dyn_first_order_solver.m
index cb5e407a8..00ae32cd2 100644
--- a/matlab/dyn_first_order_solver.m
+++ b/matlab/dyn_first_order_solver.m
@@ -244,14 +244,13 @@ else
         if nba > nsfwrd
             temp = temp(nd-nba+1:nd-nsfwrd)-1-DynareOptions.qz_criterium;
             info(1) = 3;
-        elseif nba < nsfwrd;
+        elseif nba < nsfwrd
             temp = temp(nd-nsfwrd+1:nd-nba)-1-DynareOptions.qz_criterium;
             info(1) = 4;
         end
         info(2) = temp'*temp;
         return
     end
-
     %First order approximation
     indx_stable_root = 1: (nd - nsfwrd);     %=> index of stable roots
     indx_explosive_root = npred + nboth + 1:nd;  %=> index of explosive roots
@@ -267,7 +266,7 @@ else
         % Z22 is near singular
         info(1) = 5;
         info(2) = -log(rc);
-        return;
+        return
     end
     gx  = -minus_gx;
     % predetermined variables
@@ -285,7 +284,7 @@ if nstatic > 0
     B_static = B(:,1:nstatic);  % submatrix containing the derivatives w.r. to static variables
 else
     B_static = [];
-end;
+end
 %static variables, backward variable, mixed variables and forward variables
 B_pred = B(:,nstatic+1:nstatic+npred+nboth);
 B_fyd = B(:,nstatic+npred+nboth+1:end);
@@ -309,12 +308,12 @@ if exo_nbr
         fu = Q' * jacobia(:,innovations_idx);
     else
         fu = jacobia(:,innovations_idx);
-    end;
+    end
 
     ghu = - A_ \ fu;
 else
     ghu = [];
-end;
+end
 
 dr.ghx = ghx;
 dr.ghu = ghu;
diff --git a/matlab/dyn_ramsey_static.m b/matlab/dyn_ramsey_static.m
index 964bede38..323acb7d3 100644
--- a/matlab/dyn_ramsey_static.m
+++ b/matlab/dyn_ramsey_static.m
@@ -125,7 +125,7 @@ if options_.steadystate_flag
     if any(imag(x(1:M.orig_endo_nbr))) %return with penalty
         resids=1+sum(abs(imag(x(1:M.orig_endo_nbr)))); %return with penalty
         steady_state=NaN(endo_nbr,1);
-        return;
+        return
     end
 
 end
diff --git a/matlab/dyn_waitbar.m b/matlab/dyn_waitbar.m
index f9665c950..746b62a47 100644
--- a/matlab/dyn_waitbar.m
+++ b/matlab/dyn_waitbar.m
@@ -30,7 +30,7 @@ if iscell(prctdone)
     prctdone=prctdone{1};
 end
 
-if prctdone==0,
+if prctdone==0
     init=1;
     if isempty(whoiam)
         whoiam=0;
@@ -38,46 +38,41 @@ if prctdone==0,
 else
     init=0;
 end
-if nargout,
+if nargout
     h=[];
 end
 
 if ~whoiam
-    
-    if isoctave || options_.console_mode
-                
-        if init,
+    if isoctave || options_.console_mode     
+        if init
             diary off;
             running_text = varargin{1};
             newString='';
-            return;
-        elseif nargin>2,
+            return
+        elseif nargin>2
             running_text =  varargin{2};
         end
-        
         if isoctave
             printf([running_text,' %3.f%% done\r'], prctdone*100);
         else
             s0=repmat('\b',1,length(newString));
             newString=sprintf([running_text,' %3.f%% done'], prctdone*100);
             fprintf([s0,'%s'],newString);
-        end
-        
+        end 
     else
-        if nargout,
+        if nargout
             h = waitbar(prctdone,varargin{:});
         else
             waitbar(prctdone,varargin{:});
         end
     end
-    
 else
-    if init,
+    if init
         running_text = varargin{1};
     elseif nargin>2
         running_text = varargin{2};
     end
-    if Parallel.Local,
+    if Parallel.Local
         waitbarTitle=['Local '];
     else
         waitbarTitle=[Parallel.ComputerName];
diff --git a/matlab/dyn_waitbar_close.m b/matlab/dyn_waitbar_close.m
index 894e4c6fa..ae8ee67e4 100644
--- a/matlab/dyn_waitbar_close.m
+++ b/matlab/dyn_waitbar_close.m
@@ -22,12 +22,12 @@ function dyn_waitbar_close(h)
 % along with Dynare.  If not, see <http://www.gnu.org/licenses/>.
 global options_
 
-if isoctave || options_.console_mode,
+if isoctave || options_.console_mode
     clear dyn_waitbar;
-    diary on,
+    diary on
     fprintf('\n');
 else
-    close(h),
+    close(h)
 end
 
 clear dyn_waitbar;
diff --git a/matlab/dynare.m b/matlab/dynare.m
index 3ab08aef4..03616f51d 100644
--- a/matlab/dynare.m
+++ b/matlab/dynare.m
@@ -114,9 +114,9 @@ else
         || ~strcmp(upper(fname(size(fname,2)-3:size(fname,2))),'.MOD') ...
             && ~strcmp(upper(fname(size(fname,2)-3:size(fname,2))),'.DYN')
         error('DYNARE: argument must be a filename with .mod or .dyn extension and must not include any other periods')
-    end;
+    end
     fnamelength = length(fname) - 4;
-end;
+end
 
 if fnamelength + length('_set_auxiliary_variables') > namelengthmax()
     error('The name of your MOD file is too long, please shorten it')
@@ -192,7 +192,7 @@ end
 disp(result)
 if ismember('onlymacro', varargin)
     disp('Preprocesser stopped after macroprocessing step because of ''onlymacro'' option.');
-    return;
+    return
 end
 
 % post-dynare-prerocessor-hook
diff --git a/matlab/dynare_estimation.m b/matlab/dynare_estimation.m
index 5d140bd18..cca524d64 100644
--- a/matlab/dynare_estimation.m
+++ b/matlab/dynare_estimation.m
@@ -82,7 +82,7 @@ if nnobs>1 || nfirstobs > 1
         if nnobs>1
             options_.nobs = nobs(i);
             M_.dname = [dname '_' int2str(nobs(i))];
-        elseif nfirstobs>1;
+        elseif nfirstobs>1
             options_.first_obs=first_obs(i);            
             M_.dname = [dname '_' int2str(first_obs(i))];
         end
@@ -97,7 +97,7 @@ if nnobs>1 || nfirstobs > 1
         end
         if nnobs>1
             oo_recursive_{nobs(i)} = oo_;
-        elseif nfirstobs>1;
+        elseif nfirstobs>1
             oo_recursive_{first_obs(i)} = oo_;
         end
     end
@@ -105,7 +105,7 @@ else
     dynare_estimation_1(var_list,dname);
 end
 
-if isnumeric(options_.mode_compute) && options_.mode_compute && options_.analytic_derivation,
+if isnumeric(options_.mode_compute) && options_.mode_compute && options_.analytic_derivation
     options_.analytic_derivation=analytic_derivation0;
 end
 
diff --git a/matlab/dynare_estimation_1.m b/matlab/dynare_estimation_1.m
index 0a27271de..cd0e28c9b 100644
--- a/matlab/dynare_estimation_1.m
+++ b/matlab/dynare_estimation_1.m
@@ -202,7 +202,7 @@ if ~isequal(options_.mode_compute,0) && ~options_.mh_posterior_mode_estimation
                 end
             end
         end
-        if options_.analytic_derivation,
+        if options_.analytic_derivation
             options_analytic_derivation_old = options_.analytic_derivation;
             options_.analytic_derivation = -1;
             if ~isempty(newratflag) && newratflag~=0 %numerical hessian explicitly specified
@@ -229,13 +229,13 @@ if ~isequal(options_.mode_compute,0) && ~options_.mh_posterior_mode_estimation
     end       
     if ~isnumeric(options_.mode_compute) || ~isequal(options_.mode_compute,6) %always already computes covariance matrix
         if options_.cova_compute == 1 %user did not request covariance not to be computed
-            if options_.analytic_derivation && strcmp(func2str(objective_function),'dsge_likelihood'),
+            if options_.analytic_derivation && strcmp(func2str(objective_function),'dsge_likelihood')
                 ana_deriv_old = options_.analytic_derivation;
                 options_.analytic_derivation = 2;
                 [junk1, junk2,junk3, junk4, hh] = feval(objective_function,xparam1, ...
                     dataset_,dataset_info,options_,M_,estim_params_,bayestopt_,bounds,oo_);
                 options_.analytic_derivation = ana_deriv_old;
-            elseif ~isnumeric(options_.mode_compute) || ~(isequal(options_.mode_compute,5) && newratflag~=1), 
+            elseif ~isnumeric(options_.mode_compute) || ~(isequal(options_.mode_compute,5) && newratflag~=1)
                 % with flag==0, we force to use the hessian from outer product gradient of optimizer 5
                 if options_.hessian.use_penalized_objective
                     penalized_objective_function = str2func('penalty_objective_function');
@@ -258,15 +258,15 @@ if ~isequal(options_.mode_compute,0) && ~options_.mh_posterior_mode_estimation
                 % densitities for outer product gradient
                 kalman_algo0 = options_.kalman_algo;
                 compute_hessian = 1;
-                if ~((options_.kalman_algo == 2) || (options_.kalman_algo == 4)),
+                if ~((options_.kalman_algo == 2) || (options_.kalman_algo == 4))
                     options_.kalman_algo=2;
-                    if options_.lik_init == 3,
+                    if options_.lik_init == 3
                         options_.kalman_algo=4;
                     end
-                elseif newratflag==0, % hh already contains outer product gradient with univariate filter
+                elseif newratflag==0 % hh already contains outer product gradient with univariate filter
                     compute_hessian = 0;                                            
                 end
-                if compute_hessian,
+                if compute_hessian
                     crit = options_.newrat.tolerance.f;
                     newratflag = newratflag>0;
                     hh = reshape(mr_hessian(xparam1,objective_function,fval,newratflag,crit,new_rat_hess_info,dataset_, dataset_info, options_,M_,estim_params_,bayestopt_,bounds,oo_), nx, nx);
@@ -530,14 +530,13 @@ if options_.particle.status
     return
 end
 
-if (~((any(bayestopt_.pshape > 0) && options_.mh_replic) || (any(bayestopt_.pshape ...
-                                                      > 0) && options_.load_mh_file)) ...
+if (~((any(bayestopt_.pshape > 0) && options_.mh_replic) || (any(bayestopt_.pshape> 0) && options_.load_mh_file)) ...
     || ~options_.smoother ) && options_.partial_information == 0  % to be fixed
     %% ML estimation, or posterior mode without Metropolis-Hastings or Metropolis without Bayesian smoothes variables
     [atT,innov,measurement_error,updated_variables,ys,trend_coeff,aK,T,R,P,PK,decomp,Trend,state_uncertainty,M_,oo_,options_,bayestopt_] = DsgeSmoother(xparam1,dataset_.nobs,transpose(dataset_.data),dataset_info.missing.aindex,dataset_info.missing.state,M_,oo_,options_,bayestopt_,estim_params_);
     [oo_,yf]=store_smoother_results(M_,oo_,options_,bayestopt_,dataset_,dataset_info,atT,innov,measurement_error,updated_variables,ys,trend_coeff,aK,P,PK,decomp,Trend,state_uncertainty);
 
-    if ~options_.nograph,
+    if ~options_.nograph
         [nbplt,nr,nc,lr,lc,nstar] = pltorg(M_.exo_nbr);
         if options_.TeX && any(strcmp('eps',cellstr(options_.graph_format)))
             fidTeX = fopen([M_.fname '_SmoothedShocks.tex'],'w');
@@ -545,7 +544,7 @@ if (~((any(bayestopt_.pshape > 0) && options_.mh_replic) || (any(bayestopt_.psha
             fprintf(fidTeX,['%% ' datestr(now,0) '\n']);
             fprintf(fidTeX,' \n');
         end
-        for plt = 1:nbplt,
+        for plt = 1:nbplt
             fh = dyn_figure(options_.nodisplay,'Name','Smoothed shocks');
             NAMES = [];
             if options_.TeX, TeXNAMES = []; end
@@ -557,7 +556,7 @@ if (~((any(bayestopt_.pshape > 0) && options_.mh_replic) || (any(bayestopt_.psha
                 marker_string{1,1}='-r';
                 marker_string{2,1}='-k';
             end
-            for i=1:nstar0,
+            for i=1:nstar0
                 k = (plt-1)*nstar+i;
                 subplot(nr,nc,i);
                 plot([1 gend],[0 0],marker_string{1,1},'linewidth',.5)
@@ -699,7 +698,7 @@ if (~((any(bayestopt_.pshape > 0) && options_.mh_replic) || (any(bayestopt_.psha
         fprintf(fidTeX,['%% ' datestr(now,0) '\n']);
         fprintf(fidTeX,' \n');
     end
-    for plt = 1:nbplt,
+    for plt = 1:nbplt
         fh = dyn_figure(options_.nodisplay,'Name','Historical and smoothed variables');
         NAMES = [];
         if options_.TeX, TeXNAMES = []; end
@@ -711,7 +710,7 @@ if (~((any(bayestopt_.pshape > 0) && options_.mh_replic) || (any(bayestopt_.psha
            marker_string{1,1}='-r';
            marker_string{2,1}='--k';
         end
-        for i=1:nstar0,
+        for i=1:nstar0
             k = (plt-1)*nstar+i;
             subplot(nr,nc,i);
             plot(1:gend,yf(k,:),marker_string{1,1},'linewidth',1)
@@ -745,7 +744,7 @@ if (~((any(bayestopt_.pshape > 0) && options_.mh_replic) || (any(bayestopt_.psha
         dyn_saveas(fh,[M_.fname '_HistoricalAndSmoothedVariables' int2str(plt)],options_.nodisplay,options_.graph_format);
         if options_.TeX && any(strcmp('eps',cellstr(options_.graph_format)))
             fprintf(fidTeX,'\\begin{figure}[H]\n');
-            for jj = 1:nstar0,
+            for jj = 1:nstar0
                 fprintf(fidTeX,'\\psfrag{%s}[1][][0.5][0]{%s}\n',deblank(NAMES(jj,:)),deblank(TeXNAMES(jj,:)));
             end
             fprintf(fidTeX,'\\centering \n');
diff --git a/matlab/dynare_estimation_init.m b/matlab/dynare_estimation_init.m
index b8e8b4ff6..30b584ce4 100644
--- a/matlab/dynare_estimation_init.m
+++ b/matlab/dynare_estimation_init.m
@@ -474,18 +474,18 @@ else
     [junk,ic] = intersect(bayestopt_.smoother_var_list,nstatic+(1:npred)');
     bayestopt_.smoother_restrict_columns = ic;
     [junk,bayestopt_.smoother_mf] = ismember(var_obs_index_dr, bayestopt_.smoother_var_list);
-end;
+end
 
-if options_.analytic_derivation,
-    if options_.lik_init == 3,
+if options_.analytic_derivation
+    if options_.lik_init == 3
         error('analytic derivation is incompatible with diffuse filter')
     end
     options_.analytic_derivation = 1;
-    if ~(exist('sylvester3','file')==2),
+    if ~(exist('sylvester3','file')==2)
         dynareroot = strrep(which('dynare'),'dynare.m','');
         addpath([dynareroot 'gensylv'])
     end
-    if estim_params_.np,
+    if estim_params_.np
         % check if steady state changes param values
         M=M_;
         M.params(estim_params_.param_vals(:,1)) = xparam1(estim_params_.nvx+estim_params_.ncx+estim_params_.nvn+estim_params_.ncn+1:end); %set parameters
@@ -497,8 +497,8 @@ if options_.analytic_derivation,
         end
         [tmp1, params] = evaluate_steady_state(oo_.steady_state,M,options_,oo_,steadystate_check_flag);
         change_flag=any(find(params-M.params));
-        if change_flag,
-            skipline();
+        if change_flag
+            skipline()
             if any(isnan(params))
                 disp('After computing the steadystate, the following parameters are still NaN: '),
                 disp(M.param_names(isnan(params),:))
@@ -609,7 +609,7 @@ if options_.load_results_after_load_mh
     end
 end
 
-if options_.mh_replic || options_.load_mh_file,
+if options_.mh_replic || options_.load_mh_file
     [current_options, options_] = check_posterior_sampler_options([], options_, bounds);
     options_.posterior_sampler_options.current_options = current_options;
 end
diff --git a/matlab/dynare_graph.m b/matlab/dynare_graph.m
index 9af832f7f..c4a2a8e12 100644
--- a/matlab/dynare_graph.m
+++ b/matlab/dynare_graph.m
@@ -42,7 +42,7 @@ subplot(dyn_graph.nr,dyn_graph.nc,nplot);
 
 line_types = dyn_graph.line_types;
 line_type = line_types{1};
-for i=1:size(y,2);
+for i=1:size(y,2)
     if length(line_types) > 1
         line_type = line_types{i};
     end
diff --git a/matlab/dynare_identification.m b/matlab/dynare_identification.m
index c84faf2c6..14ff50c79 100644
--- a/matlab/dynare_identification.m
+++ b/matlab/dynare_identification.m
@@ -78,48 +78,48 @@ end
 options_ident = set_default_option(options_ident,'lik_init',1);
 options_ident = set_default_option(options_ident,'analytic_derivation',1);
 
-if isfield(options_ident,'nograph'),
+if isfield(options_ident,'nograph')
     options_.nograph=options_ident.nograph;
 end
-if isfield(options_ident,'nodisplay'),
+if isfield(options_ident,'nodisplay')
     options_.nodisplay=options_ident.nodisplay;
 end
-if isfield(options_ident,'graph_format'),
+if isfield(options_ident,'graph_format')
     options_.graph_format=options_ident.graph_format;
 end
-if isfield(options_ident,'prior_trunc'),
+if isfield(options_ident,'prior_trunc')
     options_.prior_trunc=options_ident.prior_trunc;
 end
 
-if options_ident.gsa_sample_file,
+if options_ident.gsa_sample_file
     GSAFolder = checkpath('gsa',M_.dname);
-    if options_ident.gsa_sample_file==1,
+    if options_ident.gsa_sample_file==1
         load([GSAFolder,filesep,fname_,'_prior'],'lpmat','lpmat0','istable');
-    elseif options_ident.gsa_sample_file==2,
+    elseif options_ident.gsa_sample_file==2
         load([GSAFolder,filesep,fname_,'_mc'],'lpmat','lpmat0','istable');
     else
         load([GSAFolder,filesep,options_ident.gsa_sample_file],'lpmat','lpmat0','istable');
     end
-    if isempty(istable),
+    if isempty(istable)
         istable=1:size(lpmat,1);
     end
-    if ~isempty(lpmat0),
+    if ~isempty(lpmat0)
         lpmatx=lpmat0(istable,:);
     else
         lpmatx=[];
     end
     pdraws0 = [lpmatx lpmat(istable,:)];
     clear lpmat lpmat0 istable;
-elseif nargin==1,
+elseif nargin==1
     pdraws0=[];
 end
 external_sample=0;
-if nargin==2 || ~isempty(pdraws0),
+if nargin==2 || ~isempty(pdraws0)
     options_ident.prior_mc=size(pdraws0,1);
     options_ident.load_ident_files = 0;
     external_sample=1;
 end
-if isempty(estim_params_),
+if isempty(estim_params_)
     options_ident.prior_mc=1;
     options_ident.prior_range=0;
     prior_exist=0;
@@ -164,28 +164,24 @@ end
 
 SampleSize = options_ident.prior_mc;
 
-if ~(exist('sylvester3','file')==2),
-
+if ~(exist('sylvester3','file')==2)
     dynareroot = strrep(which('dynare'),'dynare.m','');
     addpath([dynareroot 'gensylv'])
 end
 
 IdentifDirectoryName = CheckPath('identification',M_.dname);
-if prior_exist,
-
+if prior_exist
     indx = [];
-    if ~isempty(estim_params_.param_vals),
+    if ~isempty(estim_params_.param_vals)
         indx = estim_params_.param_vals(:,1);
     end
     indexo=[];
     if ~isempty(estim_params_.var_exo)
         indexo = estim_params_.var_exo(:,1);
     end
-
     nparam = length(bayestopt_.name);
     np = estim_params_.np;
-
-    if estim_params_.nvn || estim_params_.ncn,
+    if estim_params_.nvn || estim_params_.ncn
         error('Identification does not support measurement errors. Instead, define them explicitly in measurement equations in model definition.')
     else
         offset = estim_params_.nvx;
@@ -229,9 +225,9 @@ else
 end
 
 skipline()
-disp(['==== Identification analysis ====' ]),
+disp(['==== Identification analysis ====' ])
 skipline()
-if nparam<2,
+if nparam<2
     options_ident.advanced=0;
     advanced = options_ident.advanced;
     disp('There is only one parameter to study for identitification.')
@@ -246,10 +242,9 @@ options_ident.max_dim_cova_group = min([options_ident.max_dim_cova_group,nparam-
 MaxNumberOfBytes=options_.MaxNumberOfBytes;
 store_options_ident = options_ident;
 
-if iload <=0,
-    
+if iload <=0
     [I,J]=find(M_.lead_lag_incidence');
-    if prior_exist,
+    if prior_exist
 %         if exist([fname_,'_mean.mat'],'file'),
 % %             disp('Testing posterior mean')
 %             load([fname_,'_mean'],'xparam1')
@@ -272,7 +267,7 @@ if iload <=0,
                 case 'calibration'
                     parameters_TeX = 'Calibration';
                     disp('Testing calibration')
-                    params(1,:) = get_all_parameters(estim_params_,M_);;
+                    params(1,:) = get_all_parameters(estim_params_,M_);
                 case 'posterior_mode'
                     parameters_TeX = 'Posterior mode';
                     disp('Testing posterior mode')
@@ -311,37 +306,37 @@ if iload <=0,
     end
     [idehess_point, idemoments_point, idemodel_point, idelre_point, derivatives_info_point, info, options_ident] = ...
         identification_analysis(params,indx,indexo,options_ident,dataset_, dataset_info, prior_exist, name_tex,1,parameters,bounds);
-    if info(1)~=0,
+    if info(1)~=0
         skipline()
         disp('----------- ')
         disp('Parameter error:')
         disp(['The model does not solve for ', parameters, ' with error code info = ', int2str(info(1))]),
         skipline()
-        if info(1)==1,
+        if info(1)==1
         disp('info==1 %! The model doesn''t determine the current variables uniquely.')
-        elseif info(1)==2,
+        elseif info(1)==2
         disp('info==2 %! MJDGGES returned an error code.')
-        elseif info(1)==3,
+        elseif info(1)==3
         disp('info==3 %! Blanchard & Kahn conditions are not satisfied: no stable equilibrium. ')
-        elseif info(1)==4,
+        elseif info(1)==4
         disp('info==4 %! Blanchard & Kahn conditions are not satisfied: indeterminacy. ')
-        elseif info(1)==5,
+        elseif info(1)==5
         disp('info==5 %! Blanchard & Kahn conditions are not satisfied: indeterminacy due to rank failure. ')
-        elseif info(1)==6,
+        elseif info(1)==6
         disp('info==6 %! The jacobian evaluated at the deterministic steady state is complex.')
-        elseif info(1)==19,
+        elseif info(1)==19
         disp('info==19 %! The steadystate routine thrown an exception (inconsistent deep parameters). ')
-        elseif info(1)==20,
+        elseif info(1)==20
         disp('info==20 %! Cannot find the steady state, info(2) contains the sum of square residuals (of the static equations). ')
-        elseif info(1)==21,
+        elseif info(1)==21
         disp('info==21 %! The steady state is complex, info(2) contains the sum of square of imaginary parts of the steady state.')
-        elseif info(1)==22,
+        elseif info(1)==22
         disp('info==22 %! The steady has NaNs. ')
-        elseif info(1)==23,
+        elseif info(1)==23
         disp('info==23 %! M_.params has been updated in the steadystate routine and has complex valued scalars. ')
-        elseif info(1)==24,
+        elseif info(1)==24
         disp('info==24 %! M_.params has been updated in the steadystate routine and has some NaNs. ')
-        elseif info(1)==30,
+        elseif info(1)==30
         disp('info==30 %! Ergodic variance can''t be computed. ')
         end
         disp('----------- ')
@@ -349,7 +344,7 @@ if iload <=0,
         if any(bayestopt_.pshape)
             disp('Try sampling up to 50 parameter sets from the prior.')
             kk=0;
-            while kk<50 && info(1),
+            while kk<50 && info(1)
                 kk=kk+1;
                 params = prior_draw();
                 [idehess_point, idemoments_point, idemodel_point, idelre_point, derivatives_info_point, info, options_ident] = ...
@@ -381,11 +376,11 @@ if iload <=0,
     save([IdentifDirectoryName '/' M_.fname '_identif.mat'], 'idehess_point', 'idemoments_point','idemodel_point', 'idelre_point','store_options_ident')
     save([IdentifDirectoryName '/' M_.fname '_' parameters '_identif.mat'], 'idehess_point', 'idemoments_point','idemodel_point', 'idelre_point','store_options_ident')
     disp_identification(params, idemodel_point, idemoments_point, name, advanced);
-    if ~options_.nograph,
+    if ~options_.nograph
         plot_identification(params,idemoments_point,idehess_point,idemodel_point,idelre_point,advanced,parameters,name,IdentifDirectoryName,parameters_TeX,name_tex);
     end
 
-    if SampleSize > 1,
+    if SampleSize > 1
         skipline()
         disp('Monte Carlo Testing')
         h = dyn_waitbar(0,'Monte Carlo identification checks ...');
@@ -399,16 +394,16 @@ if iload <=0,
         iteration = 1;
         pdraws = [];
     end
-    while iteration < SampleSize,
+    while iteration < SampleSize
         loop_indx = loop_indx+1;
-        if external_sample,
+        if external_sample
             params = pdraws0(iteration+1,:);
         else
             params = prior_draw();
         end
         [dum1, ideJ, ideH, ideGP, dum2 , info, options_MC] = ...
             identification_analysis(params,indx,indexo,options_MC,dataset_, dataset_info, prior_exist, name_tex,0,[],bounds);
-        if iteration==0 && info(1)==0,
+        if iteration==0 && info(1)==0
             MAX_tau   = min(SampleSize,ceil(MaxNumberOfBytes/(size(ideH.siH,1)*nparam)/8));
             stoH = zeros([size(ideH.siH,1),nparam,MAX_tau]);
             stoJJ = zeros([size(ideJ.siJ,1),nparam,MAX_tau]);
@@ -439,7 +434,7 @@ if iload <=0,
             idemoments.V = zeros(SampleSize,nparam,min(8,nparam));
             delete([IdentifDirectoryName '/' M_.fname '_identif_*.mat'])
         end
-        if info(1)==0,
+        if info(1)==0
             iteration = iteration + 1;
             run_index = run_index + 1;
             TAU(:,iteration)=ideH.TAU;
@@ -469,9 +464,9 @@ if iload <=0,
             stoH(:,:,run_index) = ideH.siH;
             stoJJ(:,:,run_index) = ideJ.siJ;
             pdraws(iteration,:) = params;
-            if run_index==MAX_tau || iteration==SampleSize,
+            if run_index==MAX_tau || iteration==SampleSize
                 file_index = file_index + 1;
-                if run_index<MAX_tau,
+                if run_index<MAX_tau
                     stoH = stoH(:,:,1:run_index);
                     stoJJ = stoJJ(:,:,1:run_index);
                     stoLRE = stoLRE(:,:,1:run_index);
@@ -484,7 +479,7 @@ if iload <=0,
                 
             end
             
-            if SampleSize > 1,
+            if SampleSize > 1
 %                 if isoctave || options_.console_mode,
 %                     console_waitbar(0,iteration/SampleSize);
 %                 else
@@ -496,21 +491,21 @@ if iload <=0,
     end
     
     
-    if SampleSize > 1,
-        if isoctave || options_.console_mode,
+    if SampleSize > 1
+        if isoctave || options_.console_mode
             fprintf('\n');
             diary on;
         else
-            close(h),
+            close(h)
         end
         normTAU=std(TAU')';
         normLRE=std(LRE')';
         normGAM=std(GAM')';
         normaliz1=std(pdraws);
         iter=0;
-        for ifile_index = 1:file_index,
+        for ifile_index = 1:file_index
             load([IdentifDirectoryName '/' M_.fname '_identif_' int2str(ifile_index) '.mat'], 'stoH', 'stoJJ', 'stoLRE')
-            for irun=1:size(stoH,3),
+            for irun=1:size(stoH,3)
                 iter=iter+1;
                 siJnorm(iter,:) = vnorm(stoJJ(:,:,irun)./repmat(normGAM,1,nparam)).*normaliz1;
                 siHnorm(iter,:) = vnorm(stoH(:,:,irun)./repmat(normTAU,1,nparam)).*normaliz1;
@@ -539,12 +534,12 @@ else
     options_.options_ident = options_ident;
 end  
 
-if nargout>3 && iload,
+if nargout>3 && iload
     filnam = dir([IdentifDirectoryName '/' M_.fname '_identif_*.mat']);
     H=[];
     JJ = [];
     gp = [];
-    for j=1:length(filnam),
+    for j=1:length(filnam)
         load([IdentifDirectoryName '/' M_.fname '_identif_',int2str(j),'.mat']);
         H = cat(3,H, stoH(:,abs(iload),:));
         JJ = cat(3,JJ, stoJJ(:,abs(iload),:));
@@ -553,70 +548,70 @@ if nargout>3 && iload,
     end
 end
 
-if iload,
+if iload
     disp(['Testing ',parameters])
     disp_identification(idehess_point.params, idemodel_point, idemoments_point, name,advanced);
-    if ~options_.nograph,
+    if ~options_.nograph
         plot_identification(idehess_point.params,idemoments_point,idehess_point,idemodel_point,idelre_point,advanced,parameters,name,IdentifDirectoryName,[],name_tex);
     end
 end
-if SampleSize > 1,
+if SampleSize > 1
     fprintf('\n')
     disp('Testing MC sample')
     disp_identification(pdraws, idemodel, idemoments, name);
-    if ~options_.nograph,
+    if ~options_.nograph
         plot_identification(pdraws,idemoments,idehess_point,idemodel,idelre,advanced,'MC sample ',name, IdentifDirectoryName,[],name_tex);
     end
-    if advanced,
+    if advanced
         jcrit=find(idemoments.ino);
-        if length(jcrit)<SampleSize,
-            if isempty(jcrit),
+        if length(jcrit)<SampleSize
+            if isempty(jcrit)
                 [dum,jmax]=max(idemoments.cond);
                 fprintf('\n')
                 tittxt = 'Draw with HIGHEST condition number';
                 fprintf('\n')
                 disp(['Testing ',tittxt, '. Press ENTER']), pause(5),
-                if ~iload,
+                if ~iload
                     [idehess_max, idemoments_max, idemodel_max, idelre_max, derivatives_info_max, info_max, options_ident] = ...
                         identification_analysis(pdraws(jmax,:),indx,indexo,options_ident,dataset_,dataset_info, prior_exist, name_tex,1,tittxt);
                     save([IdentifDirectoryName '/' M_.fname '_identif.mat'], 'idehess_max', 'idemoments_max','idemodel_max', 'idelre_max', 'jmax', '-append');
                 end
                 disp_identification(pdraws(jmax,:), idemodel_max, idemoments_max, name,1);
                 close all,
-                if ~options_.nograph,
+                if ~options_.nograph
                     plot_identification(pdraws(jmax,:),idemoments_max,idehess_max,idemodel_max,idelre_max,1,tittxt,name,IdentifDirectoryName,tittxt,name_tex);
                 end
                 [dum,jmin]=min(idemoments.cond);
                 fprintf('\n')
                 tittxt = 'Draw with SMALLEST condition number';
                 fprintf('\n')
-                disp(['Testing ',tittxt, '. Press ENTER']), pause(5),
-                if ~iload,
+                disp(['Testing ',tittxt, '. Press ENTER']), pause(5)
+                if ~iload
                     [idehess_min, idemoments_min, idemodel_min, idelre_min, derivatives_info_min, info_min, options_ident] = ...
                         identification_analysis(pdraws(jmin,:),indx,indexo,options_ident,dataset_, dataset_info, prior_exist, name_tex,1,tittxt);
                     save([IdentifDirectoryName '/' M_.fname '_identif.mat'], 'idehess_min', 'idemoments_min','idemodel_min', 'idelre_min', 'jmin', '-append');
                 end
                 disp_identification(pdraws(jmin,:), idemodel_min, idemoments_min, name,1);
                 close all,
-                if ~options_.nograph,
+                if ~options_.nograph
                     plot_identification(pdraws(jmin,:),idemoments_min,idehess_min,idemodel_min,idelre_min,1,tittxt,name,IdentifDirectoryName,tittxt,name_tex);
                 end
             else
-                for j=1:length(jcrit),
+                for j=1:length(jcrit)
                     tittxt = ['Rank deficient draw n. ',int2str(j)];
                     fprintf('\n')
                     disp(['Testing ',tittxt, '. Press ENTER']), pause(5),
-                    if ~iload,
+                    if ~iload
                         [idehess_(j), idemoments_(j), idemodel_(j), idelre_(j), derivatives_info_(j), info_resolve, options_ident] = ...
                             identification_analysis(pdraws(jcrit(j),:),indx,indexo,options_ident,dataset_, dataset_info, prior_exist, name_tex,1,tittxt);
                     end
                     disp_identification(pdraws(jcrit(j),:), idemodel_(j), idemoments_(j), name,1);
-                    close all,
-                    if ~options_.nograph,
+                    close all
+                    if ~options_.nograph
                         plot_identification(pdraws(jcrit(j),:),idemoments_(j),idehess_(j),idemodel_(j),idelre_(j),1,tittxt,name,IdentifDirectoryName,tittxt,name_tex);
                     end
                 end
-                if ~iload,
+                if ~iload
                     save([IdentifDirectoryName '/' M_.fname '_identif.mat'], 'idehess_', 'idemoments_','idemodel_', 'idelre_', 'jcrit', '-append');
                 end
             end
@@ -625,13 +620,13 @@ if SampleSize > 1,
 end
 
 if isoctave
-    warning('on'),
+    warning('on')
 else
-    warning on,
+    warning on
 end
 
 skipline()
-disp(['==== Identification analysis completed ====' ]),
+disp(['==== Identification analysis completed ====' ])
 skipline(2)
 
 options_ = options0_;
diff --git a/matlab/dynare_resolve.m b/matlab/dynare_resolve.m
index a2fad992a..0911fec75 100644
--- a/matlab/dynare_resolve.m
+++ b/matlab/dynare_resolve.m
@@ -90,7 +90,7 @@ switch nargin
         ic = [ nstatic+(1:nspred) endo_nbr+(1:size(DynareResults.dr.ghx,2)-nspred) ]';
     else
         ic = DynareResults.dr.restrict_columns;
-    end;
+    end
   case 4
     iv = DynareResults.dr.restrict_var_list;
     ic = DynareResults.dr.restrict_columns;
diff --git a/matlab/dynare_sensitivity.m b/matlab/dynare_sensitivity.m
index 62f688ec7..d84300c9a 100644
--- a/matlab/dynare_sensitivity.m
+++ b/matlab/dynare_sensitivity.m
@@ -32,36 +32,36 @@ lgy_ = M_.endo_names;
 x0=[];
 
 % check user defined options
-if isfield(options_gsa,'neighborhood_width') && options_gsa.neighborhood_width,
-    if isfield(options_gsa,'pprior') && options_gsa.pprior,
+if isfield(options_gsa,'neighborhood_width') && options_gsa.neighborhood_width
+    if isfield(options_gsa,'pprior') && options_gsa.pprior
         error('sensitivity:: neighborhood_width is incompatible with prior sampling')
     end
-    if isfield(options_gsa,'ppost') && options_gsa.ppost,
+    if isfield(options_gsa,'ppost') && options_gsa.ppost
         error('sensitivity:: neighborhood_width is incompatible with posterior sampling')
     end
 end
 
-if isfield(options_gsa,'morris') && options_gsa.morris==1,
-    if isfield(options_gsa,'identification') && options_gsa.identification==0,
+if isfield(options_gsa,'morris') && options_gsa.morris==1
+    if isfield(options_gsa,'identification') && options_gsa.identification==0
 %         options_gsa.redform=1;
     end
-    if isfield(options_gsa,'ppost') && options_gsa.ppost,
+    if isfield(options_gsa,'ppost') && options_gsa.ppost
         error('sensitivity:: Morris is incompatible with posterior sampling')
-    elseif isfield(options_gsa,'pprior') && options_gsa.pprior==0,
-        if ~(isfield(options_gsa,'neighborhood_width') && options_gsa.neighborhood_width),
+    elseif isfield(options_gsa,'pprior') && options_gsa.pprior==0
+        if ~(isfield(options_gsa,'neighborhood_width') && options_gsa.neighborhood_width)
             error('sensitivity:: Morris is incompatible with MC sampling with correlation matrix')
         end
     end
-    if isfield(options_gsa,'rmse') && options_gsa.rmse,
+    if isfield(options_gsa,'rmse') && options_gsa.rmse
         error('sensitivity:: Morris is incompatible with rmse analysis')
     end
     if (isfield(options_gsa,'alpha2_stab') && options_gsa.alpha2_stab<1) || ...
             (isfield(options_gsa,'pvalue_ks') && options_gsa.pvalue_ks) || ...
             (isfield(options_gsa,'pvalue_corr') && options_gsa.pvalue_corr)
-
         error('sensitivity:: Morris is incompatible with Monte Carlo filtering')
     end
 end
+
 % end check user defined options
 options_gsa = set_default_option(options_gsa,'datafile',[]);
 options_gsa = set_default_option(options_gsa,'rmse',0);
@@ -69,51 +69,50 @@ options_gsa = set_default_option(options_gsa,'useautocorr',0);
 
 options_gsa = set_default_option(options_gsa,'moment_calibration',options_.endogenous_prior_restrictions.moment);
 options_gsa = set_default_option(options_gsa,'irf_calibration',options_.endogenous_prior_restrictions.irf);
-if isfield(options_gsa,'nograph'),
+if isfield(options_gsa,'nograph')
     options_.nograph=options_gsa.nograph;
 end
-if isfield(options_gsa,'nodisplay'),
+if isfield(options_gsa,'nodisplay')
     options_.nodisplay=options_gsa.nodisplay;
 end
-if isfield(options_gsa,'graph_format'),
+if isfield(options_gsa,'graph_format')
     options_.graph_format=options_gsa.graph_format;
 end
-if isfield(options_gsa,'mode_file'),
+if isfield(options_gsa,'mode_file')
     options_.mode_file=options_gsa.mode_file;
-elseif isfield(options_gsa,'neighborhood_width') && options_gsa.neighborhood_width>0,
-    options_.mode_file='';    
+elseif isfield(options_gsa,'neighborhood_width') && options_gsa.neighborhood_width>0
+    options_.mode_file='';
 end
 
 options_.order = 1;
 
-if ~isempty(options_gsa.datafile) || isempty(bayestopt_) || options_gsa.rmse,
-    if isempty(options_gsa.datafile) && options_gsa.rmse,
+if ~isempty(options_gsa.datafile) || isempty(bayestopt_) || options_gsa.rmse
+    if isempty(options_gsa.datafile) && options_gsa.rmse
         disp('The data file and all relevant estimation options ')
         disp('[first_obs, nobs, presample, prefilter, loglinear, lik_init, kalman_algo, ...]')
         disp('must be specified for RMSE analysis!');
-        error('Sensitivity anaysis error!');
+        error('Sensitivity anaysis error!')
     end
-    
     options_.datafile = options_gsa.datafile;
-    if isfield(options_gsa,'first_obs'),
+    if isfield(options_gsa,'first_obs')
         options_.first_obs=options_gsa.first_obs;
     end
-    if isfield(options_gsa,'nobs'),
+    if isfield(options_gsa,'nobs')
         options_.nobs=options_gsa.nobs;
     end
-    if isfield(options_gsa,'presample'),
+    if isfield(options_gsa,'presample')
         options_.presample=options_gsa.presample;
     end
-    if isfield(options_gsa,'prefilter'),
+    if isfield(options_gsa,'prefilter')
         options_.prefilter=options_gsa.prefilter;
     end
-    if isfield(options_gsa,'loglinear'),
+    if isfield(options_gsa,'loglinear')
         options_.loglinear=options_gsa.loglinear;
     end
-    if isfield(options_gsa,'lik_init'),
+    if isfield(options_gsa,'lik_init')
         options_.lik_init=options_gsa.lik_init;
     end
-    if isfield(options_gsa,'kalman_algo'),
+    if isfield(options_gsa,'kalman_algo')
         options_.kalman_algo=options_gsa.kalman_algo;
     end
     options_.mode_compute = 0;
@@ -124,25 +123,25 @@ if ~isempty(options_gsa.datafile) || isempty(bayestopt_) || options_gsa.rmse,
 else
     if isempty(options_.qz_criterium)
         options_.qz_criterium = 1+1e-6;
-    end    
+    end
 end
 [make,my,day,punk,M_,options_,oo_] = dynare_resolve(M_,options_,oo_);
 
 options_gsa = set_default_option(options_gsa,'identification',0);
-if options_gsa.identification,
+if options_gsa.identification
     options_gsa.redform=0;
     options_gsa = set_default_option(options_gsa,'morris',1);
     options_gsa = set_default_option(options_gsa,'trans_ident',0);
     options_gsa = set_default_option(options_gsa,'load_ident_files',0);
     options_gsa = set_default_option(options_gsa,'ar',1);
     options_.ar = options_gsa.ar;
-    if options_gsa.morris==0,
+    if options_gsa.morris==0
         disp('The option morris = 0 is no longer supported (Type I errors)')
         disp('This option is reset at morris = 2 (local identification analysis).')
         options_gsa.morris=2;
     end
-    if options_gsa.morris==2,
-        if isfield(options_,'options_ident'),
+    if options_gsa.morris==2
+        if isfield(options_,'options_ident')
             options_.options_ident.load_ident_files = options_gsa.load_ident_files;
             options_.options_ident.useautocorr = options_gsa.useautocorr;
             options_.options_ident.ar = options_gsa.ar;            
@@ -199,27 +198,27 @@ options_gsa = set_default_option(options_gsa,'istart_rmse',options_.presample+1)
 options_gsa = set_default_option(options_gsa,'alpha_rmse',0.001);
 options_gsa = set_default_option(options_gsa,'alpha2_rmse',1.e-5);
 
-if options_gsa.neighborhood_width,
+if options_gsa.neighborhood_width
     options_gsa.pprior=0;
     options_gsa.ppost=0;
 end
 
-if options_gsa.redform && options_gsa.neighborhood_width==0 && isempty(options_gsa.threshold_redform),
+if options_gsa.redform && options_gsa.neighborhood_width==0 && isempty(options_gsa.threshold_redform)
     options_gsa.pprior=1;
     options_gsa.ppost=0;
 end
 
-if options_gsa.morris>2,
+if options_gsa.morris>2
     disp('The option morris = 3 is no longer supported')
     disp('the option is reset at morris = 1 .')
     options_gsa.morris=1;
 end
    
-if options_gsa.morris==1,
-    if ~options_gsa.identification,
+if options_gsa.morris==1
+    if ~options_gsa.identification
         options_gsa.redform=1;
     end
-    if options_gsa.neighborhood_width,
+    if options_gsa.neighborhood_width
         options_gsa.pprior=0;
     else
         options_gsa.pprior=1;
@@ -244,38 +243,37 @@ end
 
 % options_.opt_gsa = options_gsa;
 
-if (options_gsa.load_stab || options_gsa.load_rmse || options_gsa.load_redform) ...
-        && options_gsa.pprior,
+if (options_gsa.load_stab || options_gsa.load_rmse || options_gsa.load_redform) && options_gsa.pprior
     filetoload=[OutputDirectoryName '/' fname_ '_prior.mat'];
-    if ~exist(filetoload),
+    if ~exist(filetoload)
         disp([filetoload,' not found!'])
         disp(['You asked to load a non existent analysis'])
         %options_gsa.load_stab=0;
-        return,
+        return
     else
-        if isempty(strmatch('bkpprior',who('-file', filetoload),'exact')),
+        if isempty(strmatch('bkpprior',who('-file', filetoload),'exact'))
             disp('Warning! Missing prior info for saved sample') % trap for files previous 
             disp('The saved files are generated with previous version of GSA package') % trap for files previous 
         else
-            load(filetoload,'bkpprior'),
+            load(filetoload,'bkpprior')
             if any(bayestopt_.pshape~=bkpprior.pshape) || ...
                     any(bayestopt_.p1~=bkpprior.p1) || ...
                     any(bayestopt_.p2~=bkpprior.p2) || ...
                     any(bayestopt_.p3(~isnan(bayestopt_.p3))~=bkpprior.p3(~isnan(bkpprior.p3))) || ...
-                    any(bayestopt_.p4(~isnan(bayestopt_.p4))~=bkpprior.p4(~isnan(bkpprior.p4))),
+                    any(bayestopt_.p4(~isnan(bayestopt_.p4))~=bkpprior.p4(~isnan(bkpprior.p4)))
                 disp('WARNING!')
                 disp('The saved sample has different priors w.r.t. to current ones!!')
                 skipline()
                 disp('Press ENTER to continue')
-                pause;
+                pause
             end
         end
     end
 end
 
-if options_gsa.stab && ~options_gsa.ppost,
+if options_gsa.stab && ~options_gsa.ppost
     x0 = stab_map_(OutputDirectoryName,options_gsa);
-    if isempty(x0),
+    if isempty(x0)
         skipline()
         disp('Sensitivity computations stopped: no parameter set provided a unique solution')
         return
@@ -286,20 +284,19 @@ end
 % redform_map(namendo, namlagendo, namexo, icomp, pprior, ilog, threshold)
 
 options_.opt_gsa = options_gsa;
-if ~isempty(options_gsa.moment_calibration) || ~isempty(options_gsa.irf_calibration),
+if ~isempty(options_gsa.moment_calibration) || ~isempty(options_gsa.irf_calibration)
     map_calibration(OutputDirectoryName, M_, options_, oo_, estim_params_,bayestopt_);
 end
 
-if options_gsa.identification,
+if options_gsa.identification
     map_ident_(OutputDirectoryName,options_gsa);
 end
 
-if options_gsa.redform && ~isempty(options_gsa.namendo),% ...
-    %         && ~options_gsa.ppost,
-    if options_gsa.ppost,
+if options_gsa.redform && ~isempty(options_gsa.namendo)
+    if options_gsa.ppost
         filnam = dir([M_.dname filesep 'metropolis' filesep '*param_irf*.mat']);
         lpmat=[];
-        for j=1:length(filnam),
+        for j=1:length(filnam)
             load ([M_.dname filesep 'metropolis' filesep M_.fname '_param_irf' int2str(j) '.mat'])
             lpmat=[lpmat; stock];
         end
@@ -320,22 +317,21 @@ if options_gsa.redform && ~isempty(options_gsa.namendo),% ...
         
         x0 = stab_map_(OutputDirectoryName,options_gsa);
     end
-    if strmatch(':',options_gsa.namendo,'exact'),
+    if strmatch(':',options_gsa.namendo,'exact')
         options_gsa.namendo=M_.endo_names(1:M_.orig_endo_nbr,:);
     end
-    if strmatch(':',options_gsa.namexo,'exact'),
+    if strmatch(':',options_gsa.namexo,'exact')
         options_gsa.namexo=M_.exo_names;
     end
-    if strmatch(':',options_gsa.namlagendo,'exact'),
+    if strmatch(':',options_gsa.namlagendo,'exact')
         options_gsa.namlagendo=M_.endo_names(1:M_.orig_endo_nbr,:);
     end
 %     options_.opt_gsa = options_gsa;
-    if options_gsa.morris==1,
+    if options_gsa.morris==1
         redform_screen(OutputDirectoryName,options_gsa);
     else
         % check existence of the SS_ANOVA toolbox
-        if isempty(options_gsa.threshold_redform) && ...
-         ~(exist('gsa_sdp','file')==6 || exist('gsa_sdp','file')==2),
+        if isempty(options_gsa.threshold_redform) && ~(exist('gsa_sdp','file')==6 || exist('gsa_sdp','file')==2)
             fprintf('\nThe "SS-ANOVA-R: MATLAB Toolbox for the estimation of Smoothing Spline ANOVA models with Recursive algorithms" is missing.\n')
             fprintf('To obtain it, go to:\n\n')
             fprintf('http://ipsc.jrc.ec.europa.eu/?id=790 \n\n')
@@ -350,26 +346,26 @@ end
 % RMSE mapping
 % function [rmse_MC, ixx] = filt_mc_(vvarvecm, loadSA, pfilt, alpha, alpha2)
 options_.opt_gsa = options_gsa;
-if options_gsa.rmse,
+if options_gsa.rmse
     if ~options_gsa.ppost
         if options_gsa.pprior
             a=whos('-file',[OutputDirectoryName,'/',fname_,'_prior'],'logpo2');
         else
             a=whos('-file',[OutputDirectoryName,'/',fname_,'_mc'],'logpo2');
         end
-        if isoctave
+        if isoctave()
             aflag=0;
-            for ja=1:length(a),
+            for ja=1:length(a)
                 aflag=aflag+strcmp('logpo2',a(ja).name);
             end
-            if aflag==0,
+            if aflag==0
                 a=[];
             else
                 a=1;
             end
         end
-        if isempty(a),
-           if options_gsa.lik_only,
+        if isempty(a)
+           if options_gsa.lik_only
                options_.smoother=0;
                options_.filter_step_ahead=[];
                options_.forecast=0;
@@ -381,13 +377,13 @@ if options_gsa.rmse,
         else
             TmpDirectoryName = ([M_.dname filesep 'gsa' filesep 'mc']);
         end
-        if exist(TmpDirectoryName,'dir');
+        if exist(TmpDirectoryName,'dir')
             mydelete([M_.fname '_filter_step_ahead*.mat'],[TmpDirectoryName filesep]);
             mydelete([M_.fname '_inno*.mat'],[TmpDirectoryName filesep]);
             mydelete([M_.fname '_smooth*.mat'],[TmpDirectoryName filesep]);
             mydelete([M_.fname '_update*.mat'],[TmpDirectoryName filesep]);
             filparam = dir([TmpDirectoryName filesep M_.fname '_param*.mat']);
-            for j=1:length(filparam),
+            for j=1:length(filparam)
                 if isempty(strmatch([M_.fname '_param_irf'],filparam(j).name))
                     delete([TmpDirectoryName filesep filparam(j).name]);
                 end
@@ -422,7 +418,7 @@ end
 options_.opt_gsa = options_gsa;
 
 
-if options_gsa.glue,
+if options_gsa.glue
     dr_ = oo_.dr;
     if options_gsa.ppost
         load([OutputDirectoryName,'/',fname_,'_post']);
@@ -434,7 +430,7 @@ if options_gsa.glue,
             load([OutputDirectoryName,'/',fname_,'_mc']);
         end
     end
-    if ~exist('x'),
+    if ~exist('x')
         disp(['No RMSE analysis is available for current options'])
         disp(['No GLUE file prepared'])
         return,
@@ -497,8 +493,8 @@ if options_gsa.glue,
         
     end
     jsmoo = length(options_.varobs);
-    for j=1:M_.endo_nbr,
-        if ~ismember(j,ismoo),
+    for j=1:M_.endo_nbr
+        if ~ismember(j,ismoo)
             jsmoo=jsmoo+1;
             vj=deblank(M_.endo_names(dr_.order_var(j),:));
             if ~options_gsa.ppost        
@@ -517,7 +513,7 @@ if options_gsa.glue,
         end
     end
     tit(M_.exo_names_orig_ord,:) = M_.exo_names;
-    for j=1:M_.exo_nbr,
+    for j=1:M_.exo_nbr
         Exo(j).name = deblank(tit(j,:));    
     end
     if ~options_gsa.ppost
diff --git a/matlab/dynare_solve.m b/matlab/dynare_solve.m
index 149d2f9ed..75659ee5e 100644
--- a/matlab/dynare_solve.m
+++ b/matlab/dynare_solve.m
@@ -80,7 +80,7 @@ i = find(~isfinite(fvec));
 if ~isempty(i)
     info = 1;
     x = NaN(size(fvec));
-    return;
+    return
 end
 
 % this test doesn't check complementarity conditions and is not used for
@@ -125,7 +125,7 @@ if options.solve_algo == 0
             [x,fval,exitval,output] = fsolve(func,x,options4fsolve);
         else
             exitval = 3;
-        end;
+        end
     end
 
     if exitval == 1
diff --git a/matlab/dynare_solve_block_or_bytecode.m b/matlab/dynare_solve_block_or_bytecode.m
index 1032d0921..d074f6bf2 100644
--- a/matlab/dynare_solve_block_or_bytecode.m
+++ b/matlab/dynare_solve_block_or_bytecode.m
@@ -80,7 +80,7 @@ elseif options.bytecode
                     info = 1;
                     return
                 end
-            end;
+            end
         end
     else
         [x, check] = dynare_solve('bytecode_steadystate', y, ...
diff --git a/matlab/dynare_squeeze.m b/matlab/dynare_squeeze.m
index b01be342f..a2797b8cb 100644
--- a/matlab/dynare_squeeze.m
+++ b/matlab/dynare_squeeze.m
@@ -1,4 +1,4 @@
-function B = dynare_squeeze(A);
+function B = dynare_squeeze(A)
 % Same as matlab's squeeze function except that it also affects 2D arrays.
 
 % Copyright (C) 2009 Dynare Team
diff --git a/matlab/endogenous_prior_restrictions.m b/matlab/endogenous_prior_restrictions.m
index 617116a89..7d6b979db 100644
--- a/matlab/endogenous_prior_restrictions.m
+++ b/matlab/endogenous_prior_restrictions.m
@@ -1,4 +1,4 @@
-function [info, info_irf, info_moment, data_irf, data_moment] = endogenous_prior_restrictions(T,R,Model,DynareOptions,DynareResults);
+function [info, info_irf, info_moment, data_irf, data_moment] = endogenous_prior_restrictions(T,R,Model,DynareOptions,DynareResults)
 % Check for prior (sign) restrictions on irf's and theoretical moments
 %
 % INPUTS
@@ -41,17 +41,17 @@ data_moment=[];
 endo_prior_restrictions.irf= DynareOptions.endogenous_prior_restrictions.irf;
 endo_prior_restrictions.moment= DynareOptions.endogenous_prior_restrictions.moment;
 
-if ~isempty(endo_prior_restrictions.irf),
+if ~isempty(endo_prior_restrictions.irf)
    data_irf=cell(size(endo_prior_restrictions.irf,1),1);    
-    if DynareOptions.order>1,
+    if DynareOptions.order>1
         error('The algorithm for prior (sign) restrictions on irf''s is currently restricted to first-order decision rules')
         return
     end
     varlist=Model.endo_names(DynareResults.dr.order_var,:);
-    if isempty(T),
+    if isempty(T)
         [T,R,SteadyState,infox,Model,DynareOptions,DynareResults] = dynare_resolve(Model,DynareOptions,DynareResults);
     else % check if T and R are given in the restricted form!!!
-        if size(T,1)<size(varlist,1),
+        if size(T,1)<size(varlist,1)
             varlist=varlist(DynareResults.dr.restrict_var_list,:); 
         end
         % check if endo_prior_restrictions.irf{:,1} variables are in varlist
@@ -67,27 +67,27 @@ if ~isempty(endo_prior_restrictions.irf),
         end
     end
     NT=1;
-    for j=1:size(endo_prior_restrictions.irf,1),
+    for j=1:size(endo_prior_restrictions.irf,1)
         NT=max(NT,max(endo_prior_restrictions.irf{j,3}));
     end
     info_irf=ones(size(endo_prior_restrictions.irf,1),2);
-    for t=1:NT,
-        if ~DynareOptions.relative_irf,
+    for t=1:NT
+        if ~DynareOptions.relative_irf
             RR = T^(t-1)*R*diag(sqrt(diag(Model.Sigma_e)));
         else
             RR = T^(t-1)*R*100;
         end
-        for j=1:size(endo_prior_restrictions.irf,1),
-            if endo_prior_restrictions.irf{j,3}~=t,
-                continue,
+        for j=1:size(endo_prior_restrictions.irf,1)
+            if endo_prior_restrictions.irf{j,3}~=t
+                continue
             end
             iendo=strmatch(endo_prior_restrictions.irf{j,1},varlist,'exact');
             iexo=strmatch(endo_prior_restrictions.irf{j,2},Model.exo_names,'exact');
             data_irf{j}=[data_irf{j}; [t RR(iendo,iexo)]];
-            if (RR(iendo,iexo)>endo_prior_restrictions.irf{j,4}(1)) && (RR(iendo,iexo)<endo_prior_restrictions.irf{j,4}(2)),
+            if (RR(iendo,iexo)>endo_prior_restrictions.irf{j,4}(1)) && (RR(iendo,iexo)<endo_prior_restrictions.irf{j,4}(2))
                 info_irf(j,:)=info_irf(j,:).*[0, 0];
             else
-                if RR(iendo,iexo)<endo_prior_restrictions.irf{j,4}(1),
+                if RR(iendo,iexo)<endo_prior_restrictions.irf{j,4}(1)
                     delt = (RR(iendo,iexo)-endo_prior_restrictions.irf{j,4}(1))^2;
                 else
                     delt = (RR(iendo,iexo)-endo_prior_restrictions.irf{j,4}(2))^2;
@@ -96,34 +96,32 @@ if ~isempty(endo_prior_restrictions.irf),
             end
         end
     end
-    if any(info_irf),
+    if any(info_irf)
         info=[49,sum(info_irf(:,2))];
     end
     
 end
 
-if ~isempty(endo_prior_restrictions.moment),
-    
-    if DynareOptions.order>1,
+if ~isempty(endo_prior_restrictions.moment)
+    if DynareOptions.order>1
         error('The algorithm for prior (sign) restrictions on moments is currently restricted to first-order decision rules')
         return
     end
-    
     data_moment=cell(size(endo_prior_restrictions.moment,1),1);
     var_list_=endo_prior_restrictions.moment{1,1};
-    for  j=1:size(endo_prior_restrictions.moment,1),
+    for  j=1:size(endo_prior_restrictions.moment,1)
         tmp=endo_prior_restrictions.moment{j,1};
-        if ~ismember(tmp,cellstr(var_list_)),
+        if ~ismember(tmp,cellstr(var_list_))
             var_list_ = char(var_list_, tmp);
         end
         tmp=endo_prior_restrictions.moment{j,2};
-        if ~ismember(tmp,cellstr(var_list_)),
+        if ~ismember(tmp,cellstr(var_list_))
             var_list_ = char(var_list_, tmp);
         end
     end
     NTmax=0;
     NTmin=0;
-    for j=1:size(endo_prior_restrictions.moment,1),
+    for j=1:size(endo_prior_restrictions.moment,1)
         NTmax=max(NTmax,max(endo_prior_restrictions.moment{j,3}));
         NTmin=min(NTmin,min(endo_prior_restrictions.moment{j,3}));
     end
@@ -133,21 +131,21 @@ if ~isempty(endo_prior_restrictions.moment),
     for i=1:nvar
         i_tmp = strmatch(var_list_(i,:),Model.endo_names,'exact');
         if isempty(i_tmp)
-            error (['One of the variable specified does not exist']) ;
+            error (['One of the variable specified does not exist'])
         else
             ivar(i) = i_tmp;
         end
     end
     DynareOptions.ar = max(abs(NTmin),NTmax);
     [gamma_y,stationary_vars] = th_autocovariances(DynareResults.dr, ivar, Model, DynareOptions,1);
-    for t=NTmin:NTmax,
+    for t=NTmin:NTmax
         RR = gamma_y{abs(t)+1};     
-        if t==0,
+        if t==0
             RR = RR./(sqrt(diag(RR))*sqrt(diag(RR))')-eye(nvar)+diag(diag(gamma_y{t+1})); % becomes correlation            
         end
-        for j=1:size(endo_prior_restrictions.moment,1),
-            if endo_prior_restrictions.moment{j,3}~=t,
-                continue,
+        for j=1:size(endo_prior_restrictions.moment,1)
+            if endo_prior_restrictions.moment{j,3}~=t
+                continue
             end
             iendo1 = strmatch(endo_prior_restrictions.moment{j,1},var_list_,'exact');
             iendo2 = strmatch(endo_prior_restrictions.moment{j,2},var_list_,'exact');
@@ -157,10 +155,10 @@ if ~isempty(endo_prior_restrictions.moment),
                 iendo2=tmp0;
             end
             data_moment{j}=[data_moment{j}; [t RR(iendo1,iendo2)]];
-            if (RR(iendo1,iendo2)>endo_prior_restrictions.moment{j,4}(1)) && (RR(iendo1,iendo2)<endo_prior_restrictions.moment{j,4}(2)),
+            if (RR(iendo1,iendo2)>endo_prior_restrictions.moment{j,4}(1)) && (RR(iendo1,iendo2)<endo_prior_restrictions.moment{j,4}(2))
                 info_moment(j,:)=info_moment(j,:).*[0, 0];
             else
-                if RR(iendo1,iendo2)<endo_prior_restrictions.moment{j,4}(1),
+                if RR(iendo1,iendo2)<endo_prior_restrictions.moment{j,4}(1)
                     delt = (RR(iendo1,iendo2)-endo_prior_restrictions.moment{j,4}(1))^2;
                 else
                     delt = (RR(iendo1,iendo2)-endo_prior_restrictions.moment{j,4}(2))^2;
@@ -169,10 +167,7 @@ if ~isempty(endo_prior_restrictions.moment),
             end
         end
     end
-    if any(info_moment),
+    if any(info_moment)
         info=[49, info(2) + sum(info_moment(:,2))];
     end
-end
-return
-
-
+end
\ No newline at end of file
diff --git a/matlab/ep/extended_path_initialization.m b/matlab/ep/extended_path_initialization.m
index 34d7cdc68..8a6117df8 100644
--- a/matlab/ep/extended_path_initialization.m
+++ b/matlab/ep/extended_path_initialization.m
@@ -134,6 +134,6 @@ if DynareOptions.ep.solve_algo == 10
 elseif DynareOptions.ep.solve_algo == 11
     DynareOptions.mcppath.lb = repmat(lb,block_nbr,1);
     DynareOptions.mcppath.ub = repmat(ub,block_nbr,1);
-end;
+end
 pfm.block_nbr = block_nbr;
 
diff --git a/matlab/ep/extended_path_shocks.m b/matlab/ep/extended_path_shocks.m
index 693990340..e83fa4f22 100644
--- a/matlab/ep/extended_path_shocks.m
+++ b/matlab/ep/extended_path_shocks.m
@@ -1,4 +1,4 @@
-function [shocks, spfm_exo_simul, innovations, DynareResults] = extended_path_shocks(innovations, ep, exogenousvariables, sample_size,DynareModel,DynareOptions, DynareResults); 
+function [shocks, spfm_exo_simul, innovations, DynareResults] = extended_path_shocks(innovations, ep, exogenousvariables, sample_size,DynareModel,DynareOptions, DynareResults)
 
 % Copyright (C) 2016 Dynare Team
 %
diff --git a/matlab/evaluate_steady_state.m b/matlab/evaluate_steady_state.m
index 053d62255..5ab906be9 100644
--- a/matlab/evaluate_steady_state.m
+++ b/matlab/evaluate_steady_state.m
@@ -67,7 +67,7 @@ function [ys,params,info] = evaluate_steady_state(ys_init,M,options,oo,steadysta
                 if options.debug
                     fprintf('\nevaluate_steady_state: The steady state file computation for the Ramsey problem resulted in NaNs.\n')
                     fprintf('evaluate_steady_state: The steady state was computed conditional on the following initial instrument values: \n')
-                    for ii = 1:size(options.instruments,1);
+                    for ii = 1:size(options.instruments,1)
                         fprintf('\t %s \t %f \n',options.instruments(ii,:),ys_init(strmatch(options.instruments(ii,:),M.endo_names,'exact')))
                     end
                     fprintf('evaluate_steady_state: The problem occured in the following equations: \n')
@@ -75,35 +75,35 @@ function [ys,params,info] = evaluate_steady_state(ys_init,M,options,oo,steadysta
                     for ii=1:length(nan_indices)
                         fprintf('%d, ',nan_indices(ii));
                     end
-                    skipline();
+                    skipline()
                     fprintf('evaluate_steady_state: If those initial values are not admissable, change them using an initval-block.\n')
-                    skipline(2);
+                    skipline(2)
                 end
                 info(1) = 84;
                 info(2) = resids'*resids;
-                return;
+                return
             end
             
             if any(imag(ys(n_multipliers+1:end)))
                 if options.debug
                     fprintf('\nevaluate_steady_state: The steady state file computation for the Ramsey problem resulted in complex numbers.\n')
                     fprintf('evaluate_steady_state: The steady state was computed conditional on the following initial instrument values: \n')
-                    for ii = 1:size(options.instruments,1);
+                    for ii = 1:size(options.instruments,1)
                         fprintf('\t %s \t %f \n',options.instruments(ii,:),ys_init(strmatch(options.instruments(ii,:),M.endo_names,'exact')))
                     end
                     fprintf('evaluate_steady_state: If those initial values are not admissable, change them using an initval-block.\n')
-                    skipline(2);
+                    skipline(2)
                 end
                 info(1) = 86;
                 info(2) = resids'*resids;
-                return;
+                return
             end
 
             if max(abs(resids(n_multipliers+1:end))) > options.solve_tolf %does it solve for all variables except for the Lagrange multipliers
                 if options.debug
                     fprintf('\nevaluate_steady_state: The steady state file does not solve the steady state for the Ramsey problem.\n')
                     fprintf('evaluate_steady_state: Conditional on the following instrument values: \n')
-                    for ii = 1:size(options.instruments,1);
+                    for ii = 1:size(options.instruments,1)
                         fprintf('\t %s \t %f \n',options.instruments(ii,:),ys_init(strmatch(options.instruments(ii,:),M.endo_names,'exact')))
                     end
                     fprintf('evaluate_steady_state: the following equations have non-zero residuals: \n')
@@ -112,11 +112,11 @@ function [ys,params,info] = evaluate_steady_state(ys_init,M,options,oo,steadysta
                             fprintf('\t Equation number %d: %f\n',ii-n_multipliers, resids(ii))
                         end
                     end
-                    skipline(2);
+                    skipline(2)
                 end
                 info(1) = 85;
                 info(2) = resids'*resids;
-                return;
+                return
             end
         end
         if options.debug
@@ -138,7 +138,7 @@ function [ys,params,info] = evaluate_steady_state(ys_init,M,options,oo,steadysta
         %either if no steady state file or steady state file without problems
         [ys,params,info] = dyn_ramsey_static(ys_init,M,options,oo);
         if info
-           return;
+           return
         end
         %check whether steady state really solves the model
         resids = evaluate_static_model(ys,exo_ss,params,M,options);
@@ -151,7 +151,7 @@ function [ys,params,info] = evaluate_steady_state(ys_init,M,options,oo,steadysta
             if options.debug
                 fprintf('\nevaluate_steady_state: The steady state computation for the Ramsey problem resulted in NaNs.\n')
                 fprintf('evaluate_steady_state: The steady state computation resulted in the following instrument values: \n')
-                for i = 1:size(options.instruments,1);
+                for i = 1:size(options.instruments,1)
                     fprintf('\t %s \t %f \n',options.instruments(i,:),ys(strmatch(options.instruments(i,:),M.endo_names,'exact')))
                 end
                 fprintf('evaluate_steady_state: The problem occured in the following equations: \n')
@@ -159,17 +159,17 @@ function [ys,params,info] = evaluate_steady_state(ys_init,M,options,oo,steadysta
                 for ii=1:length(nan_indices)
                     fprintf('%d, ',nan_indices(ii));
                 end
-                skipline();
+                skipline()
             end
             info(1) = 82;
-            return;
+            return
         end
 
         if ~isempty(nan_indices_multiplier)
             if options.debug
                 fprintf('\nevaluate_steady_state: The steady state computation for the Ramsey problem resulted in NaNs in the auxiliary equations.\n')
                 fprintf('evaluate_steady_state: The steady state computation resulted in the following instrument values: \n')
-                for i = 1:size(options.instruments,1);
+                for i = 1:size(options.instruments,1)
                     fprintf('\t %s \t %f \n',options.instruments(i,:),ys(strmatch(options.instruments(i,:),M.endo_names,'exact')))
                 end
                 fprintf('evaluate_steady_state: The problem occured in the following equations: \n')
@@ -177,17 +177,17 @@ function [ys,params,info] = evaluate_steady_state(ys_init,M,options,oo,steadysta
                 for ii=1:length(nan_indices_multiplier)
                     fprintf('%d, ',nan_indices_multiplier(ii));
                 end
-                skipline();
+                skipline()
             end
             info(1) = 83;
-            return;
+            return
         end
 
         if max(abs(resids)) > options.solve_tolf %does it solve for all variables including the auxiliary ones
             if options.debug
                 fprintf('\nevaluate_steady_state: The steady state for the Ramsey problem could not be computed.\n')
                 fprintf('evaluate_steady_state: The steady state computation stopped with the following instrument values:: \n')
-                for i = 1:size(options.instruments,1);
+                for i = 1:size(options.instruments,1)
                     fprintf('\t %s \t %f \n',options.instruments(i,:),ys(strmatch(options.instruments(i,:),M.endo_names,'exact')))
                 end
                 fprintf('evaluate_steady_state: The following equations have non-zero residuals: \n')
@@ -201,21 +201,20 @@ function [ys,params,info] = evaluate_steady_state(ys_init,M,options,oo,steadysta
                         fprintf('\t Equation number %d: %f\n',ii-n_multipliers, resids(ii))
                     end
                 end
-                skipline(2);
+                skipline(2)
             end
             info(1) = 81;
             info(2) = resids'*resids;
-            return;
+            return
         end
     elseif steadystate_flag
         % explicit steady state file
-        [ys,params,info] = evaluate_steady_state_file(ys_init,exo_ss,M, ...
-                                                       options,steadystate_check_flag);
+        [ys,params,info] = evaluate_steady_state_file(ys_init,exo_ss,M, options,steadystate_check_flag);
         if size(ys,2)>size(ys,1)
             error('STEADY: steady_state-file must return a column vector, not a row vector.')
         end
         if info(1)
-            return;
+            return
         end
     elseif (options.bytecode == 0 && options.block == 0)
         if options.linear == 0
@@ -268,7 +267,6 @@ function [ys,params,info] = evaluate_steady_state(ys_init,M,options,oo,steadysta
                     fprintf('STEADY: No steady state for your model could be found\n')
                     fprintf('STEADY: Check whether your model is truly linear. Put "resid(1);" before "steady;" to see the problematic equations.\n')
                 end
-
             else
                 ys = ys_init;
             end
@@ -285,8 +283,7 @@ function [ys,params,info] = evaluate_steady_state(ys_init,M,options,oo,steadysta
         end
     else
         % block or bytecode
-        [ys,check] = dynare_solve_block_or_bytecode(ys_init,exo_ss, params, ...
-                                                    options, M);
+        [ys,check] = dynare_solve_block_or_bytecode(ys_init,exo_ss, params, options, M);
     end
 
     if check
@@ -320,7 +317,6 @@ function [ys,params,info] = evaluate_steady_state(ys_init,M,options,oo,steadysta
             xys = z(iyr0);
             r = feval([M.fname '_dynamic'], z(iyr0), zx, M.params, ys, M.maximum_lag + 1);
         end
-
         % Fail if residual greater than tolerance
         if max(abs(r)) > options.solve_tolf
             info(1) = 25;
diff --git a/matlab/evaluate_steady_state_file.m b/matlab/evaluate_steady_state_file.m
index 8f67a5b87..fbb3cf030 100644
--- a/matlab/evaluate_steady_state_file.m
+++ b/matlab/evaluate_steady_state_file.m
@@ -134,7 +134,7 @@ function [ys,params,info] = evaluate_steady_state_file(ys_init,exo_ss,M,options,
         if check
             info(1) = 19;
             info(2) = check; % to be improved
-            return;
+            return
         end
         if max(abs(residuals)) > options.dynatol.f
             info(1) = 19;
diff --git a/matlab/fjaco.m b/matlab/fjaco.m
index 5217ca93a..63a218af0 100644
--- a/matlab/fjaco.m
+++ b/matlab/fjaco.m
@@ -34,7 +34,7 @@ h = tol.*max(abs(x),1);
 xh1=x+h; xh0=x-h;
 h=xh1-xh0;
 fjac = NaN(length(ff),length(x));
-for j=1:length(x);
+for j=1:length(x)
     xx = x;
     xx(j) = xh1(j); f1=feval(f,xx,varargin{:});
     xx(j) = xh0(j); f0=feval(f,xx,varargin{:});
diff --git a/matlab/flip_plan.m b/matlab/flip_plan.m
index a5a0952a9..dc9794a83 100644
--- a/matlab/flip_plan.m
+++ b/matlab/flip_plan.m
@@ -38,12 +38,12 @@ function plan = flip_plan(plan, exogenous, endogenous, expectation_type, date, v
   ix = find(strcmp(exogenous, plan.endo_names));
   if  isempty(ix)
       error(['in flip_plan the second argument ' exogenous ' is not an endogenous variable']);
-  end;
+  end
   endogenous = strtrim(endogenous);
   iy = find(strcmp(endogenous, plan.exo_names));
   if  isempty(iy)
       error(['in flip_plan the third argument ' endogenous ' is not an exogenous variable']);
-  end;
+  end
   sdate = length(date);
   if sdate > 1
       if date(1) < plan.date(1) || date(end) > plan.date(end)
diff --git a/matlab/forecast_graphs.m b/matlab/forecast_graphs.m
index 50e682c3a..108e0498b 100644
--- a/matlab/forecast_graphs.m
+++ b/matlab/forecast_graphs.m
@@ -63,7 +63,7 @@ m = 1;
 n_fig = 1;
 hh=dyn_figure(options_.nodisplay,'Name','Forecasts (I)');
 for j= 1:nvar
-    if m > nc*nr; 
+    if m > nc*nr
         dyn_saveas(hh,[ dname '/graphs/forcst' int2str(n_fig)],options_.nodisplay,options_.graph_format);
         if options_.TeX && any(strcmp('eps',cellstr(options_.graph_format)))
             fprintf(fidTeX,'\\begin{figure}[H]\n');
@@ -127,7 +127,7 @@ if isfield(oo_.forecast,'HPDinf_ME')
     n_fig = 1;
     hh=dyn_figure(options_.nodisplay,'Name','Forecasts including ME (I)');
     for j= 1:length(var_names)
-        if m > nc*nr;
+        if m > nc*nr
             dyn_saveas(hh,[ dname '/graphs/forcst_ME' int2str(n_fig)],options_.nodisplay,options_.graph_format);
             if options_.TeX && any(strcmp('eps',cellstr(options_.graph_format)))
                 fprintf(fidTeX,'\\begin{figure}[H]\n');
diff --git a/matlab/formdata.m b/matlab/formdata.m
index 06dba8416..159853645 100644
--- a/matlab/formdata.m
+++ b/matlab/formdata.m
@@ -29,6 +29,7 @@ function formdata(fname,date)
 % along with Dynare.  If not, see <http://www.gnu.org/licenses/>.
 
 global M_ oo_
+
 fid = fopen([fname '_endo.frm'],'w');
 n=size(oo_.endo_simul,1);
 t=size(oo_.endo_simul,2);
@@ -46,11 +47,10 @@ for i=1:n
             fprintf(fid,'%10.5f %10.5f\n',oo_.endo_simul(i,floor(t/4)*4+1:t));
           case 3
             fprintf(fid,'%10.5f %10.5f %10.5f\n',oo_.endo_simul(i,floor(t/4)*4+1:t));
-        end;
-        %else
-        %    fprintf(fid,'\n');
-    end;
-end;
+        end
+    end
+end
+
 fclose(fid);
 
 fid = fopen([fname '_exo.frm'],'w');
@@ -70,10 +70,8 @@ for i=1:n
             fprintf(fid,'%10.5f %10.5f\n',oo_.exo_simul(floor(t/4)*4+1:t,i)');
           case 3
             fprintf(fid,'%10.5f %10.5f %10.5f\n',oo_.exo_simul(floor(t/4)*4+1:t,i)');
-        end;
-        %else
-        %    fprintf(fid,'\n');
-    end;
-end;
-fclose(fid);
-return;
\ No newline at end of file
+        end
+    end
+end
+
+fclose(fid);
\ No newline at end of file
diff --git a/matlab/gensylv/gensylv.m b/matlab/gensylv/gensylv.m
index 26624fea7..3eb389fcf 100644
--- a/matlab/gensylv/gensylv.m
+++ b/matlab/gensylv/gensylv.m
@@ -36,9 +36,9 @@ function [err, E] = gensylv(kron_prod,A,B,C0,D)
 % You should have received a copy of the GNU General Public License
 % along with Dynare.  If not, see <http://www.gnu.org/licenses/>.
 C = C0;
-for i=1:(kron_prod-1);
+for i=1:(kron_prod-1)
     C  = kron(C0,C); 
-end;
+end
 
 x0 = sylvester3(A,B,C,D);
 E  = sylvester3a(x0,A,B,C,D);
diff --git a/matlab/gensylv/sylvester3.m b/matlab/gensylv/sylvester3.m
index be4d8c574..a94e389b7 100644
--- a/matlab/gensylv/sylvester3.m
+++ b/matlab/gensylv/sylvester3.m
@@ -23,21 +23,21 @@ m = size(c,1);
 p = size(d,3);
 x=zeros(n,m,p);
 if n == 1
-    for j=1:p,
+    for j=1:p
         x(:,:,j)=d(:,:,j)./(a*ones(1,m)+b*c);
     end
     return
 end
 if m == 1
-    for j=1:p,
+    for j=1:p
         x(:,:,j) = (a+c*b)\d(:,:,j);
     end
-    return;
+    return
 end
 [u,t]=schur(c);
 if isoctave
     [aa,bb,qq,zz]=qz(full(a),full(b));
-    for j=1:p,
+    for j=1:p
         if octave_ver_less_than('3.4.0')
             d(:,:,j)=qq'*d(:,:,j)*u;
         else
@@ -46,7 +46,7 @@ if isoctave
     end
 else
     [aa,bb,qq,zz]=qz(full(a),full(b),'real'); % available in Matlab version 6.0
-    for j=1:p,
+    for j=1:p
         d(:,:,j)=qq*d(:,:,j)*u;
     end
 end
@@ -58,7 +58,7 @@ while i < m
         if i == 1
             c = zeros(n,1,p);
         else
-            for j=1:p,
+            for j=1:p
                 c(:,:,j) = bb*(x(:,1:i-1,j)*t(1:i-1,i));
             end
         end
@@ -69,7 +69,7 @@ while i < m
             c = zeros(n,1,p);
             c1 = zeros(n,1,p);
         else
-            for j=1:p,
+            for j=1:p
                 c(:,:,j) = bb*(x(:,1:i-1,j)*t(1:i-1,i));
                 c1(:,:,j) = bb*(x(:,1:i-1,j)*t(1:i-1,i+1));
             end
@@ -82,13 +82,13 @@ while i < m
     end
 end
 if i == m
-    for j=1:p,
+    for j=1:p
         c(:,:,j) = bb*(x(:,1:m-1,j)*t(1:m-1,m));
     end
     aabbt = (aa+bb*t(m,m));
     x(:,m,:)=aabbt\squeeze(d(:,m,:)-c);
 end
-for j=1:p,
+for j=1:p
     x(:,:,j)=zz*x(:,:,j)*u';
 end
 
diff --git a/matlab/gensylv/sylvester3a.m b/matlab/gensylv/sylvester3a.m
index 00724dc38..744a7ee85 100644
--- a/matlab/gensylv/sylvester3a.m
+++ b/matlab/gensylv/sylvester3a.m
@@ -21,7 +21,7 @@ function [x0, flag]=sylvester3a(x0,a,b,c,dd)
 a_1 = inv(a);
 b = a_1*b;
 flag=0;
-for j=1:size(dd,3),
+for j=1:size(dd,3)
     d = a_1*dd(:,:,j);
     e = 1;
     iter = 1;
diff --git a/matlab/gensylv_fp.m b/matlab/gensylv_fp.m
index 2e5c167b5..73ad0b315 100644
--- a/matlab/gensylv_fp.m
+++ b/matlab/gensylv_fp.m
@@ -50,11 +50,11 @@ if isempty(hxo)
     X = zeros(size(B, 2), size(C, 1));
 else
     X = hxo;
-end;
+end
 it_fp = 0;
 maxit_fp = 1000;
 Z = - (B * X * C + D);
-while it_fp < maxit_fp && evol > tol;
+while it_fp < maxit_fp && evol > tol
     %X_old = X;
     %X = - A1 * ( B * X * C + D);
     %evol = max(max(abs(X - X_old)));
@@ -64,10 +64,10 @@ while it_fp < maxit_fp && evol > tol;
     evol = max(sum(abs(Z - Z_old))); %norm_1
     %evol = max(sum(abs(Z - Z_old)')); %norm_inf
     it_fp = it_fp + 1;
-end;
+end
 %fprintf('sylvester it_fp=%d evol=%g | ',it_fp,evol);
 if evol < tol
     eval(['hxo_' int2str(block) ' = X;']);
 else
     error(['convergence not achieved in fixed point solution of Sylvester equation after ' int2str(it_fp) ' iterations']);
-end;
\ No newline at end of file
+end
\ No newline at end of file
diff --git a/matlab/getH.m b/matlab/getH.m
index 0db11d8e3..4bfa6949d 100644
--- a/matlab/getH.m
+++ b/matlab/getH.m
@@ -66,7 +66,7 @@ end
 yy0=oo_.dr.ys(I);
 param_nbr = length(indx);
 tot_param_nbr = param_nbr + length(indexo);
-if nargout>5,
+if nargout>5
     param_nbr_2 = param_nbr*(param_nbr+1)/2;
     tot_param_nbr_2 = tot_param_nbr*(tot_param_nbr+1)/2;
 end
@@ -75,18 +75,18 @@ m = size(A,1);
 m1=length(iv);
 n = size(B,2);
 
-if kronflag==-1, % perturbation
+if kronflag==-1 % perturbation
     gp=0;
     fun = 'thet2tau';
     params0 = M_.params;
     H = fjaco(fun,[sqrt(diag(M_.Sigma_e(indexo,indexo))); M_.params(indx)], M_, oo_, indx, indexo,0);
-    if nargout>1,
+    if nargout>1
         dOm = zeros(m1,m1,tot_param_nbr);
         dA=zeros(m1,m1,tot_param_nbr);
         Hss=H(iv,length(indexo)+1:end);
         da = H(m+1:m+m*m,:);
         dom = H(m+m*m+1:end,:);
-        for j=1:tot_param_nbr,
+        for j=1:tot_param_nbr
             tmp = dyn_unvech(dom(:,j));
             dOm(:,:,j) = tmp(iv,iv);
             tmp = reshape(da(:,j),m,m);
@@ -94,13 +94,13 @@ if kronflag==-1, % perturbation
         end
         clear da dom tmp
     end
-    if nargout>5,
+    if nargout>5
         H2 = hessian_sparse('thet2tau',[sqrt(diag(M_.Sigma_e(indexo,indexo))); M_.params(indx)], ...
             options_.gstep,estim_params_,M_, oo_, indx,indexo,0,[],[],[],iv);
         H2ss = zeros(m1,tot_param_nbr,tot_param_nbr);
         iax=find(triu(rand(tot_param_nbr,tot_param_nbr)));
         H2 = H2(:,iax);
-        for j=1:m1,
+        for j=1:m1
             H2ss(j,:,:)=dyn_unvech(full(H2(j,:)));
         end
         H2ss=H2ss(:,length(indexo)+1:end,length(indexo)+1:end);
@@ -122,20 +122,20 @@ if kronflag==-1, % perturbation
     return
 end
 
-if kronflag==-2,
-    if nargout>5,
+if kronflag==-2
+    if nargout>5
         [residual, g1, g2 ] = feval([M_.fname,'_dynamic'],yy0, oo_.exo_steady_state', ...
             M_.params, oo_.dr.ys, 1);
         g22 = hessian_sparse('thet2tau',[M_.params(indx)],options_.gstep,estim_params_,M_, oo_, indx,[],-1);
         H2ss=full(g22(1:M_.endo_nbr,:));
         H2ss = reshape(H2ss,[M_.endo_nbr param_nbr param_nbr]);
-        for j=1:M_.endo_nbr,
+        for j=1:M_.endo_nbr
             H2ss(j,:,:)=dyn_unvech(dyn_vech(H2ss(j,:,:)));
         end
         g22=g22(M_.endo_nbr+1:end,:);
         inx=find(g22);
         gx22=zeros(length(inx),5);
-        for j=1:length(inx),
+        for j=1:length(inx)
             [i1, i2] = ind2sub(size(g22),inx(j));
             [ig1, ig2] = ind2sub(size(g1),i1);
             [ip1, ip2] = ind2sub([param_nbr param_nbr],i2);
@@ -152,18 +152,13 @@ if kronflag==-2,
     gp=gp(M_.endo_nbr+1:end,:);
     gp = reshape(gp,[size(g1) param_nbr]);
 else
-
-% yy0=[];
-% for j=1:size(M_.lead_lag_incidence,1);
-%     yy0 = [ yy0; oo_.dr.ys(find(M_.lead_lag_incidence(j,:)))];
-% end
 dyssdtheta=zeros(length(oo_.dr.ys),M_.param_nbr);
 d2yssdtheta=zeros(length(oo_.dr.ys),M_.param_nbr,M_.param_nbr);
 [residual, gg1] = feval([M_.fname,'_static'],oo_.dr.ys, oo_.exo_steady_state', M_.params);
 df = feval([M_.fname,'_static_params_derivs'],oo_.dr.ys, repmat(oo_.exo_steady_state',[M_.maximum_exo_lag+M_.maximum_exo_lead+1]), ...
     M_.params);
 dyssdtheta = -gg1\df;
-if nargout>5,
+if nargout>5
     [residual, gg1, gg2] = feval([M_.fname,'_static'],oo_.dr.ys, oo_.exo_steady_state', M_.params);
     [residual, g1, g2, g3] = feval([M_.fname,'_dynamic'],yy0, oo_.exo_steady_state', ...
         M_.params, oo_.dr.ys, 1);
@@ -172,27 +167,25 @@ if nargout>5,
     [df, gpx, d2f] = feval([M_.fname,'_static_params_derivs'],oo_.dr.ys, oo_.exo_steady_state', ...
         M_.params);%, oo_.dr.ys, 1, dyssdtheta*0, d2yssdtheta);
     d2f = get_all_resid_2nd_derivs(d2f,length(oo_.dr.ys),M_.param_nbr);
-
-    if isempty(find(gg2)),
-        for j=1:M_.param_nbr,
+    if isempty(find(gg2))
+        for j=1:M_.param_nbr
         d2yssdtheta(:,:,j) = -gg1\d2f(:,:,j);
         end
     else
         gam = d2f*0;
-        for j=1:nr,
+        for j=1:nr
             tmp1 = (squeeze(gpx(j,:,:))'*dyssdtheta);
             gam(j,:,:)=transpose(reshape(gg2(j,:),[nr nr])*dyssdtheta)*dyssdtheta ...
                 + tmp1 + tmp1';
         end
-        for j=1:M_.param_nbr,
+        for j=1:M_.param_nbr
         d2yssdtheta(:,:,j) = -gg1\(d2f(:,:,j)+gam(:,:,j));
-%         d2yssdtheta(:,:,j) = -gg1\(d2f(:,:,j)+gam(:,:,j)+ squeeze(gpx(:,:,j))*dyssdtheta);
         end
-        clear tmp1 gpx gam,
+        clear tmp1 gpx gam
     end
 end
 
-if any(any(isnan(dyssdtheta))),    
+if any(any(isnan(dyssdtheta)))
     [U,T] = schur(gg1);
     qz_criterium=options_.qz_criterium;
     e1 = abs(ordeig(T)) < qz_criterium-1;
@@ -201,19 +194,16 @@ if any(any(isnan(dyssdtheta))),
     [U,T] = ordschur(U,T,e1);
     T = T(k+1:end,k+1:end);
     dyssdtheta = -U(:,k+1:end)*(T\U(:,k+1:end)')*df;
-    if nargout>5,
-        for j=1:length(indx),
+    if nargout>5
+        for j=1:length(indx)
             d2yssdtheta(:,:,j) = -U(:,k+1:end)*(T\U(:,k+1:end)')*d2f(:,:,j);
         end
     end
 end
-if nargout>5,
+if nargout>5
     [df, gp, d2f, gpp, hp] = feval([M_.fname,'_params_derivs'],yy0, oo_.exo_steady_state', ...
         M_.params, oo_.dr.ys, 1, dyssdtheta, d2yssdtheta);
     H2ss = d2yssdtheta(oo_.dr.order_var,indx,indx);
-%     nelem=size(g1,2);
-%     g22 = get_all_2nd_derivs(gpp,m,nelem,M_.param_nbr);
-%     g22 = g22(:,:,indx,indx);
 else
     [df, gp] = feval([M_.fname,'_params_derivs'],yy0, repmat(oo_.exo_steady_state',[M_.maximum_exo_lag+M_.maximum_exo_lead+1,1]), ...
         M_.params, oo_.dr.ys, 1, dyssdtheta,d2yssdtheta);
@@ -227,12 +217,12 @@ Hss = dyssdtheta(oo_.dr.order_var,indx);
 dyssdtheta = dyssdtheta(I,:);
 ns = max(max(M_.lead_lag_incidence)); % retrieve the number of states excluding columns for shocks
 gp2 = gp*0;
-for j=1:nr,
+for j=1:nr
     [II JJ]=ind2sub([nc nc],find(g2(j,:)));
-    for i=1:nc,
+    for i=1:nc
         is = find(II==i);
         is = is(find(JJ(is)<=ns));
-        if ~isempty(is),
+        if ~isempty(is)
             g20=full(g2(j,find(g2(j,:))));
             gp2(j,i,:)=g20(is)*dyssdtheta(JJ(is),:);
         end
@@ -242,7 +232,7 @@ end
 gp = gp+gp2;
 gp = gp(:,:,indx);
 
-if nargout>5,
+if nargout>5
 %     h22 = get_all_hess_derivs(hp,nr,nc,M_.param_nbr);
     g22 = gpp;
     gp22 = sparse(nr*nc,param_nbr*param_nbr);
@@ -251,16 +241,16 @@ if nargout>5,
 %     tmp2=tmp1*[dyssdtheta; zeros(nc-ns,M_.param_nbr)];
     tmpa=[dyssdtheta; zeros(nc-ns,M_.param_nbr)];
     tmpa=sparse(tmpa);
-    for j=1:M_.param_nbr,
+    for j=1:M_.param_nbr
         tmp2(:,j)=tmp1*tmpa(:,j);
     end
 %     tmp2=sparse(tmp2);
 %     [i1 i2]=ind2sub([nc M_.param_nbr],[1:nc*M_.param_nbr]');
 
-    for j=1:nr,
+    for j=1:nr
         tmp0=reshape(g2(j,:),[nc nc]);   
         tmp0 = tmp0(:,1:ns)*reshape(d2yssdtheta(I,:,:),[ns,M_.param_nbr*M_.param_nbr]);
-        for i=1:nc,
+        for i=1:nc
             indo = sub2ind([nr nc nc], ones(nc,1)*j ,ones(nc,1)*i, (1:nc)');
             tmpx = (tmp2(indo,:))'*[dyssdtheta; zeros(nc-ns,M_.param_nbr)];
 %             gp22(j,i,:,:)=squeeze(tmp1(j,i,:,:))'*[dyssdtheta; zeros(nc-ns,M_.param_nbr)];
@@ -268,7 +258,7 @@ if nargout>5,
             tmpy = tmpx+tmpu+tmpu'+reshape(tmp0(i,:,:),[M_.param_nbr M_.param_nbr]);
             tmpy = tmpy + get_2nd_deriv_mat(gpp,j,i,M_.param_nbr);
             tmpy = tmpy(indx,indx);
-            if any(any(tmpy)),
+            if any(any(tmpy))
                 ina = find(triu(tmpy));
                 gp22(sub2ind([nr nc],j,i),ina)=transpose(tmpy(ina));
 %             gp22(j,i,:,:)= reshape(tmpy,[1 1 M_.param_nbr M_.param_nbr]);
@@ -280,10 +270,10 @@ if nargout>5,
 
 %     g22 = g22+gp22;
 %     g22 = g22(:,:,indx,indx);
-    clear tmp0 tmp1 tmp2 tmpu tmpx tmpy,
+    clear tmp0 tmp1 tmp2 tmpu tmpx tmpy
         inx=find(gp22);
         gx22=zeros(length(inx),5);
-        for j=1:length(inx),
+        for j=1:length(inx)
             [i1, i2] = ind2sub(size(gp22),inx(j));
             [ig1, ig2] = ind2sub(size(g1),i1);
             [ip1, ip2] = ind2sub([param_nbr param_nbr],i2);
@@ -301,15 +291,14 @@ klen = M_.maximum_endo_lag + M_.maximum_endo_lead + 1;
 k11 = M_.lead_lag_incidence(find([1:klen] ~= M_.maximum_endo_lag+1),:);
 a = g1(:,nonzeros(k11'));
 da = gp(:,nonzeros(k11'),:);
-if nargout > 5,
+if nargout > 5
     indind = ismember(g22(:,2),nonzeros(k11'));
     tmp = g22(indind,:);
     d2a=tmp;
-    for j=1:size(tmp,1),
+    for j=1:size(tmp,1)
         inxinx = find(nonzeros(k11')==tmp(j,2));
         d2a(j,2) = inxinx;
     end
-%     d2a = g22(:,nonzeros(k11'),:,:);
 end
 kstate = oo_.dr.kstate;
 
@@ -319,12 +308,12 @@ Dg1 = zeros(M_.endo_nbr,M_.endo_nbr,param_nbr);
 k1 = find(kstate(:,2) == M_.maximum_endo_lag+2 & kstate(:,3));
 GAM1(:, kstate(k1,1)) = -a(:,kstate(k1,3));
 Dg1(:, kstate(k1,1), :) = -da(:,kstate(k1,3),:);
-if nargout > 5,
+if nargout > 5
     indind = ismember(d2a(:,2),kstate(k1,3));
     tmp = d2a(indind,:);
     tmp(:,end)=-tmp(:,end);
     D2g1 = tmp;
-    for j=1:size(tmp,1),
+    for j=1:size(tmp,1)
         inxinx = (kstate(k1,3)==tmp(j,2));
         D2g1(j,2) = kstate(k1(inxinx),1);
     end
@@ -336,11 +325,11 @@ GAM0 = zeros(M_.endo_nbr,M_.endo_nbr);
 Dg0 = zeros(M_.endo_nbr,M_.endo_nbr,param_nbr);
 GAM0(:,cols_b) = g1(:,cols_j);
 Dg0(:,cols_b,:) = gp(:,cols_j,:);
-if nargout > 5,
+if nargout > 5
     indind = ismember(g22(:,2),cols_j);
     tmp = g22(indind,:);
     D2g0=tmp;
-    for j=1:size(tmp,1),
+    for j=1:size(tmp,1)
         inxinx = (cols_j==tmp(j,2));
         D2g0(j,2) = cols_b(inxinx);
     end
@@ -352,12 +341,12 @@ GAM2 = zeros(M_.endo_nbr,M_.endo_nbr);
 Dg2 = zeros(M_.endo_nbr,M_.endo_nbr,param_nbr);
 GAM2(:, kstate(k2,1)) = -a(:,kstate(k2,4));
 Dg2(:, kstate(k2,1), :) = -da(:,kstate(k2,4),:);
-if nargout > 5,
+if nargout > 5
     indind = ismember(d2a(:,2),kstate(k2,4));
     tmp = d2a(indind,:);
     tmp(:,end)=-tmp(:,end);
     D2g2 = tmp;
-    for j=1:size(tmp,1),
+    for j=1:size(tmp,1)
         inxinx = (kstate(k2,4)==tmp(j,2));
         D2g2(j,2) = kstate(k2(inxinx),1);
     end
@@ -365,13 +354,13 @@ end
 
 GAM3 = -g1(:,length(yy0)+1:end);
 Dg3 = -gp(:,length(yy0)+1:end,:);
-if nargout>5,
+if nargout>5
     cols_ex = [length(yy0)+1:size(g1,2)];
     indind = ismember(g22(:,2),cols_ex);
     tmp = g22(indind,:);
     tmp(:,end)=-tmp(:,end);
     D2g3=tmp;
-    for j=1:size(tmp,1),
+    for j=1:size(tmp,1)
         inxinx = find(cols_ex==tmp(j,2));
         D2g3(j,2) = inxinx;
     end
@@ -380,11 +369,11 @@ end
 
 clear g1 g2 g3 df d2f gpp hp residual gg1 gg2 gp2 dyssdtheta d2yssdtheta
 
-if kronflag==1, % kronecker products
+if kronflag==1 % kronecker products
     Dg0=reshape(Dg0,m^2,param_nbr);
     Dg1=reshape(Dg1,m^2,param_nbr);
     Dg2=reshape(Dg2,m^2,param_nbr);
-    for j=1:param_nbr,
+    for j=1:param_nbr
         Dg3(:,:,j)=Dg3(:,:,j)*M_.Sigma_e;
     end
     Dg3=reshape(Dg3,m*n,param_nbr);
@@ -427,7 +416,7 @@ if kronflag==1, % kronecker products
     H(m*m+1:end,:) = tmpH(Index,:);
 
     Hx = [];
-    if ~isempty(indexo),
+    if ~isempty(indexo)
         dSig = zeros(M_.exo_nbr,M_.exo_nbr);
         dOm = cat(3,zeros(size(dOm,1),size(dOm,1),length(indexo)),dOm);
         for j=1:length(indexo)
@@ -435,7 +424,7 @@ if kronflag==1, % kronecker products
             y = B*dSig*B';
             y = y(nauxe+1:end,nauxe+1:end);
             Hx(:,j) = [zeros((m-nauxe)^2,1); dyn_vech(y)];
-            if nargout>1,
+            if nargout>1
                 dOm(:,:,j) = y;
             end
             dSig(indexo(j),indexo(j)) = 0;
@@ -452,24 +441,24 @@ else % generalized sylvester equation
     c = A;
     elem = zeros(m,m,param_nbr);
     d = elem;
-    for j=1:param_nbr,
+    for j=1:param_nbr
         elem(:,:,j) = (Dg0(:,:,j)-Dg1(:,:,j)*A);
         d(:,:,j) = Dg2(:,:,j)-elem(:,:,j)*A;
     end
     xx=sylvester3(a,b,c,d);
     flag=1;
     icount=0;
-    while flag && icount<4,
+    while flag && icount<4
         [xx, flag]=sylvester3a(xx,a,b,c,d);
         icount=icount+1;
     end
     H=zeros(m1*m1+m1*(m1+1)/2,param_nbr+length(indexo));
-    if nargout>1,
+    if nargout>1
         dOm = zeros(m1,m1,param_nbr+length(indexo));
         dA=zeros(m1,m1,param_nbr+length(indexo));
         dB=zeros(m,n,param_nbr);
     end
-    if ~isempty(indexo),
+    if ~isempty(indexo)
         dSig = zeros(M_.exo_nbr,M_.exo_nbr,length(indexo));
         for j=1:length(indexo)
             dSig(indexo(j),indexo(j),j) = 2*sqrt(M_.Sigma_e(indexo(j),indexo(j)));
@@ -477,22 +466,22 @@ else % generalized sylvester equation
 %             y = y(nauxe+1:end,nauxe+1:end);
 %             H(:,j) = [zeros((m-nauxe)^2,1); dyn_vech(y)];
             H(:,j) = [zeros(m1^2,1); dyn_vech(y(iv,iv))];
-            if nargout>1,
+            if nargout>1
                 dOm(:,:,j) = y(iv,iv);
             end
 %             dSig(indexo(j),indexo(j)) = 0;
         end
     end
-    for j=1:param_nbr,
+    for j=1:param_nbr
         x = xx(:,:,j);
         y = inva * (Dg3(:,:,j)-(elem(:,:,j)-GAM1*x)*B);
-        if nargout>1,
+        if nargout>1
             dB(:,:,j) = y;
         end
         y = y*M_.Sigma_e*B'+B*M_.Sigma_e*y';
 %         x = x(nauxe+1:end,nauxe+1:end);
 %         y = y(nauxe+1:end,nauxe+1:end);
-        if nargout>1,
+        if nargout>1
             dA(:,:,j+length(indexo)) = x(iv,iv);
             dOm(:,:,j+length(indexo)) = y(iv,iv);
         end
@@ -515,7 +504,7 @@ else % generalized sylvester equation
 
 end
 
-if nargout > 5,
+if nargout > 5
     H2ss = H2ss(iv,:,:);
     d = zeros(m,m,floor(sqrt(param_nbr_2)));
     %     d2A = zeros(m,m,tot_param_nbr,tot_param_nbr);
@@ -533,8 +522,8 @@ if nargout > 5,
     jinx = [];
     x2x=sparse(m*m,param_nbr_2);
 %     x2x=[];
-    for i=1:param_nbr,
-        for j=1:i,
+    for i=1:param_nbr
+        for j=1:i
             elem1 = (get_2nd_deriv(D2g0,m,m,j,i)-get_2nd_deriv(D2g1,m,m,j,i)*A);
             elem1 = get_2nd_deriv(D2g2,m,m,j,i)-elem1*A;
             elemj0 = Dg0(:,:,j)-Dg1(:,:,j)*A;
@@ -545,15 +534,15 @@ if nargout > 5,
             jcount=jcount+1;
             jinx = [jinx; [j i]];
             d(:,:,jcount) = elem1+elem2;
-            if jcount==floor(sqrt(param_nbr_2)) || (j*i)==param_nbr^2,
-                if (j*i)==param_nbr^2,
+            if jcount==floor(sqrt(param_nbr_2)) || (j*i)==param_nbr^2
+                if (j*i)==param_nbr^2
                     d = d(:,:,1:jcount);
                 end
 %                 d(find(abs(d)<1.e-12))=0;
                 xx2=sylvester3(a,b,c,d);
                 flag=1;
                 icount=0;
-                while flag && icount<4,
+                while flag && icount<4
                     [xx2, flag]=sylvester3a(xx2,a,b,c,d);
                     icount = icount + 1;
                 end
@@ -583,11 +572,11 @@ if nargout > 5,
     offset = length(indexo);
     %     d2B = zeros(m,n,tot_param_nbr,tot_param_nbr);
     d2Sig = zeros(M_.exo_nbr,M_.exo_nbr,length(indexo));
-    for j=1:tot_param_nbr,
-        for i=1:j,
+    for j=1:tot_param_nbr
+        for i=1:j
             jcount=jcount+1;
-            if j<=offset,
-                if i==j,
+            if j<=offset
+                if i==j
                     d2Sig(indexo(j),indexo(j),j) = 2;
                     y = B*d2Sig(:,:,j)*B';
 %                     y(abs(y)<1.e-8)=0;
@@ -596,7 +585,7 @@ if nargout > 5,
             else
                 jind = j-offset;
                 iind = i-offset;
-                if i<=offset,
+                if i<=offset
                     y = dB(:,:,jind)*dSig(:,:,i)*B'+B*dSig(:,:,i)*dB(:,:,jind)';
 %                     y(abs(y)<1.e-8)=0;
                     d2Om_tmp(:,jcount) = dyn_vech(y(iv,iv));
@@ -620,7 +609,7 @@ if nargout > 5,
                     d2Om_tmp(:,jcount) = dyn_vech(y(iv,iv));
                 end
             end
-            if jcount==ncol || i*j==tot_param_nbr^2,
+            if jcount==ncol || i*j==tot_param_nbr^2
                 d2A(:,cumjcount+1:cumjcount+jcount) = d2A_tmp(:,1:jcount);
                 %         d2A(:,:,j+length(indexo),i+length(indexo)) = x;
                 %         d2A(:,:,i+length(indexo),j+length(indexo)) = x;
@@ -643,35 +632,35 @@ end
 
 return
 
-function g22 = get_2nd_deriv(gpp,m,n,i,j),
+function g22 = get_2nd_deriv(gpp,m,n,i,j)
 
 g22=zeros(m,n);
 is=find(gpp(:,3)==i);
 is=is(find(gpp(is,4)==j));
 
-if ~isempty(is),
+if ~isempty(is)
     g22(sub2ind([m,n],gpp(is,1),gpp(is,2)))=gpp(is,5)';
 end
 return
 
-function g22 = get_2nd_deriv_mat(gpp,i,j,n),
+function g22 = get_2nd_deriv_mat(gpp,i,j,n)
 
 g22=zeros(n,n);
 is=find(gpp(:,1)==i);
 is=is(find(gpp(is,2)==j));
 
-if ~isempty(is),
+if ~isempty(is)
     g22(sub2ind([n,n],gpp(is,3),gpp(is,4)))=gpp(is,5)';
     g22(sub2ind([n,n],gpp(is,4),gpp(is,3)))=gpp(is,5)';
 end
 return
 
-function g22 = get_all_2nd_derivs(gpp,m,n,npar,fsparse),
+function g22 = get_all_2nd_derivs(gpp,m,n,npar,fsparse)
 
-if nargin==4 || isempty(fsparse),
+if nargin==4 || isempty(fsparse)
     fsparse=0;
 end
-if fsparse,
+if fsparse
     g22=sparse(m*n,npar*npar);
 else
 g22=zeros(m,n,npar,npar);
@@ -680,11 +669,11 @@ end
 % c=triu(c);
 % ic=find(c);
 
-for is=1:length(gpp),
+for is=1:length(gpp)
 %     d=zeros(npar,npar);
 %     d(gpp(is,3),gpp(is,4))=1;
 %     indx = find(ic==find(d));
-    if fsparse,
+    if fsparse
         g22(sub2ind([m,n],gpp(is,1),gpp(is,2)),sub2ind([npar,npar],gpp(is,3),gpp(is,4)))=gpp(is,5);
         g22(sub2ind([m,n],gpp(is,1),gpp(is,2)),sub2ind([npar,npar],gpp(is,4),gpp(is,3)))=gpp(is,5);
     else
@@ -695,14 +684,14 @@ end
 
 return
 
-function r22 = get_all_resid_2nd_derivs(rpp,m,npar),
+function r22 = get_all_resid_2nd_derivs(rpp,m,npar)
 
 r22=zeros(m,npar,npar);
 % c=ones(npar,npar);
 % c=triu(c);
 % ic=find(c);
 
-for is=1:length(rpp),
+for is=1:length(rpp)
 %     d=zeros(npar,npar);
 %     d(rpp(is,2),rpp(is,3))=1;
 %     indx = find(ic==find(d));
@@ -712,31 +701,31 @@ end
 
 return
 
-function h2 = get_all_hess_derivs(hp,r,m,npar),
+function h2 = get_all_hess_derivs(hp,r,m,npar)
 
 h2=zeros(r,m,m,npar);
 
-for is=1:length(hp),
+for is=1:length(hp)
     h2(hp(is,1),hp(is,2),hp(is,3),hp(is,4))=hp(is,5);
     h2(hp(is,1),hp(is,3),hp(is,2),hp(is,4))=hp(is,5);
 end
 
 return
 
-function h2 = get_hess_deriv(hp,i,j,m,npar),
+function h2 = get_hess_deriv(hp,i,j,m,npar)
 
 h2=zeros(m,npar);
 is1=find(hp(:,1)==i);
 is=is1(find(hp(is1,2)==j));
 
-if ~isempty(is),
+if ~isempty(is)
     h2(sub2ind([m,npar],hp(is,3),hp(is,4)))=hp(is,5)';
 end
 
 is=is1(find(hp(is1,3)==j));
 
-if ~isempty(is),
+if ~isempty(is)
     h2(sub2ind([m,npar],hp(is,2),hp(is,4)))=hp(is,5)';
 end
 
-return
+return
\ No newline at end of file
diff --git a/matlab/getJJ.m b/matlab/getJJ.m
index b7686a035..e2a90c0bb 100644
--- a/matlab/getJJ.m
+++ b/matlab/getJJ.m
@@ -56,10 +56,10 @@ function [JJ, H, gam, gp, dA, dOm, dYss] = getJJ(A, B, estim_params_, M_,oo_,opt
 
 if nargin<8 || isempty(indx)
 %     indx = [1:M_.param_nbr];
-end,
+end
 if nargin<9 || isempty(indexo)
     indexo = [];
-end,
+end
 if nargin<11 || isempty(nlags)
     nlags=3; 
 end
@@ -70,7 +70,7 @@ end
 %   if useautocorr,
 warning('off','MATLAB:divideByZero')
 %   end
-if kronflag == -1,
+if kronflag == -1
     fun = 'thet2tau';
     params0 = M_.params;
     para0 = get_all_parameters(estim_params_, M_);
@@ -87,7 +87,7 @@ if kronflag == -1,
     dYss = H(1:M_.endo_nbr,offset+1:end);
     dA = reshape(H(M_.orig_endo_nbr+[1:numel(A)],:),[size(A),size(H,2)]);
     dOm = dA*0;
-    for j=1:size(H,2),
+    for j=1:size(H,2)
         dOm(:,:,j) = dyn_unvech(H(M_.endo_nbr+numel(A)+1:end,j));
     end
     assignin('base','M_', M_);
@@ -115,7 +115,7 @@ else
     %     BB(:,:,j)= dA(:,:,j)*GAM*A'+A*GAM*dA(:,:,j)'+dOm(:,:,j);
     %   end
     %   XX =  lyapunov_symm_mr(A,BB,options_.qz_criterium,options_.lyapunov_complex_threshold,0);
-    for j=1:length(indexo),
+    for j=1:length(indexo)
         dum =  lyapunov_symm(A,dOm(:,:,j),options_.lyapunov_fixed_point_tol,options_.qz_criterium,options_.lyapunov_complex_threshold,2,options_.debug);
         %     dum =  XX(:,:,j);
         k = find(abs(dum) < 1e-12);
@@ -130,7 +130,7 @@ else
         else
             dumm = dyn_vech(dum(mf,mf));
         end
-        for i=1:nlags,
+        for i=1:nlags
             dum1 = A^i*dum;
             if useautocorr
                 dum1 = (dum1.*sy-dsy.*(A^i*GAM))./(sy.*sy);
@@ -140,7 +140,7 @@ else
         JJ(:,j) = dumm;
     end
     nexo = length(indexo);
-    for j=1:length(indx),
+    for j=1:length(indx)
         dum =  lyapunov_symm(A,dA(:,:,j+nexo)*GAM*A'+A*GAM*dA(:,:,j+nexo)'+dOm(:,:,j+nexo),options_.lyapunov_fixed_point_tol,options_.qz_criterium,options_.lyapunov_complex_threshold,2,options_.debug);
         %     dum =  XX(:,:,j);
         k = find(abs(dum) < 1e-12);
@@ -155,9 +155,9 @@ else
         else
             dumm = dyn_vech(dum(mf,mf));
         end
-        for i=1:nlags,
+        for i=1:nlags
             dum1 = A^i*dum;
-            for ii=1:i,
+            for ii=1:i
                 dum1 = dum1 + A^(ii-1)*dA(:,:,j+nexo)*A^(i-ii)*GAM;
             end
             if useautocorr
@@ -171,23 +171,23 @@ else
     JJ = [ [zeros(length(mf),nexo) dYss(mf,:)]; JJ];
     
 end
-if nargout >2,
+if nargout >2
     %     sy=sy(mf,mf);
     options_.ar=nlags;
     nodecomposition = 1;
     [GAM,stationary_vars] = th_autocovariances(oo_.dr,oo_.dr.order_var(mf),M_,options_,nodecomposition);
     sy=sqrt(diag(GAM{1}));
     sy=sy*sy';
-    if useautocorr,
+    if useautocorr
         sy=sy-diag(diag(sy))+eye(length(mf));
         GAM{1}=GAM{1}./sy;
     else
-        for j=1:nlags,
+        for j=1:nlags
             GAM{j+1}=GAM{j+1}.*sy;
         end
     end
     gam = dyn_vech(GAM{1});
-    for j=1:nlags,
+    for j=1:nlags
         gam = [gam; vec(GAM{j+1})];
     end
 end
diff --git a/matlab/get_Hessian.m b/matlab/get_Hessian.m
index a42b3c812..a591644ff 100644
--- a/matlab/get_Hessian.m
+++ b/matlab/get_Hessian.m
@@ -128,13 +128,13 @@ function [Hess] = get_Hessian(T,R,Q,H,P,Y,DT,DYss,DOm,DH,DP,D2T,D2Yss,D2Om,D2H,D
             t = t+1;
             v = Y(:,t)-a(mf);
             tmp = (a+K*v);
-            for ii = 1:k,
+            for ii = 1:k
                 Dv(:,ii)   = -Da(mf,ii)-DYss(mf,ii);
                 dKi  = DK(:,:,ii);
                 diFi = -iF*DF(:,:,ii)*iF;
                 dtmpi = Da(:,ii)+dKi*v+K*Dv(:,ii);
                 
-                for jj = 1:ii,
+                for jj = 1:ii
                     dFj    = DF(:,:,jj);
                     diFj   = -iF*DF(:,:,jj)*iF;
                     dKj  = DK(:,:,jj);
@@ -191,7 +191,7 @@ end
 
 % end of computeDKalman
 
-function [d2K,d2S,d2P1] = computeD2Kalman(A,dA,d2A,d2Om,P0,dP0,d2P0,DH,mf,iF,K0,dK0);
+function [d2K,d2S,d2P1] = computeD2Kalman(A,dA,d2A,d2Om,P0,dP0,d2P0,DH,mf,iF,K0,dK0)
 % computes the second derivatives of the Kalman matrices
 % note: A=T in main func.
         
diff --git a/matlab/get_new_or_existing_ei_index.m b/matlab/get_new_or_existing_ei_index.m
index 39bec99a3..e1c71f193 100644
--- a/matlab/get_new_or_existing_ei_index.m
+++ b/matlab/get_new_or_existing_ei_index.m
@@ -38,7 +38,7 @@ global estimation_info
 
 if eval(['isempty(estimation_info.' substructure_name ')'])
     indx = 1;
-    return;
+    return
 end
 
 if isempty(name2) % parameter or std() statement
diff --git a/matlab/graph_decomp.m b/matlab/graph_decomp.m
index 6fae28f3b..2993699cf 100644
--- a/matlab/graph_decomp.m
+++ b/matlab/graph_decomp.m
@@ -52,7 +52,7 @@ fig_name_long = opts_decomp.fig_name;
 
 use_shock_groups = DynareOptions.plot_shock_decomp.use_shock_groups;
 screen_shocks = opts_decomp.screen_shocks;
-if use_shock_groups | comp_nbr<=18,
+if use_shock_groups | comp_nbr<=18
     screen_shocks=0;
 end
 if use_shock_groups
@@ -94,20 +94,20 @@ if DynareOptions.TeX && any(strcmp('eps',cellstr(DynareOptions.plot_shock_decomp
     fprintf(fidTeX,' \n');
 end
 
-if opts_decomp.vintage && opts_decomp.realtime>1,
+if opts_decomp.vintage && opts_decomp.realtime>1
     preamble_txt = 'Shock decomposition';
 else
     preamble_txt = 'Historical shock decomposition';
 end
 
-if ~(screen_shocks && comp_nbr>18),
+if ~(screen_shocks && comp_nbr>18)
     screen_shocks=0;
 end
 comp_nbr0=comp_nbr;
 %%plot decomposition
 for j=1:nvar
     z1 = squeeze(z(i_var(j),:,:));
-    if screen_shocks,
+    if screen_shocks
         [junk, isort] = sort(mean(abs(z1(1:end-2,:)')), 'descend');
         labels = char(char(shock_names(isort(1:16),:)),'Others', 'Initial values');
         zres = sum(z1(isort(17:end),:),1);
@@ -153,14 +153,14 @@ for j=1:nvar
     plot(ax,x(2:end),z1(end,:),'k-','LineWidth',2)
     if ~isempty(SteadyState)
         plot(ax,[xmin xmax],[0 0],'--','linewidth',1,'color',[0.7 0.7 0.7])
-        if ymin+SteadyState(i_var(j))<0 && ymax+SteadyState(i_var(j))>0,
+        if ymin+SteadyState(i_var(j))<0 && ymax+SteadyState(i_var(j))>0
             plot(ax,[xmin xmax],SteadyState(i_var(j))*[-1 -1],'k--','linewidth',1)
             ytick=get(ax,'ytick');
             ytick1=ytick-SteadyState(i_var(j));
             ind1=min(find(ytick1>=ymin));
             ind2=max(find(ytick1<=ymax));
             dytick=ytick(2)-ytick(1);
-            if ind1>1,
+            if ind1>1
                 ytick1  = [ytick1(ind1:end) ytick1(end)+dytick:dytick:ymax];
             elseif ind2<length(ytick)
                 ytick1= [sort(ytick1(1)-dytick:-dytick:ymin) ytick1(1:ind2)];
diff --git a/matlab/graph_decomp_detail.m b/matlab/graph_decomp_detail.m
index 077653ea6..5d42d0ce1 100644
--- a/matlab/graph_decomp_detail.m
+++ b/matlab/graph_decomp_detail.m
@@ -52,7 +52,7 @@ if ~isempty(opts_decomp.type)
     fig_mode = [fig_mode '_'];
 end
 screen_shocks = opts_decomp.screen_shocks;
-if DynareOptions.plot_shock_decomp.use_shock_groups | comp_nbr<=18,
+if DynareOptions.plot_shock_decomp.use_shock_groups | comp_nbr<=18
     screen_shocks=0;
 end
 fig_name_long = opts_decomp.fig_name;
@@ -85,7 +85,7 @@ end
 
 ind_yrs = find(floor(x)==x); 
 dind_tick = 1;
-if floor(length(ind_yrs)/3);
+if floor(length(ind_yrs)/3)
     dind_tick = floor(length(ind_yrs)/3);
     xind_tick = x(ind_yrs(1)):dind_tick:x(ind_yrs(end))+(length(ind_yrs)-(dind_tick*3+1));
 else
@@ -112,7 +112,7 @@ if DynareOptions.TeX && any(strcmp('eps',cellstr(DynareOptions.plot_shock_decomp
     fprintf(fidTeX,' \n');
 end
 
-if opts_decomp.vintage && opts_decomp.realtime>1,
+if opts_decomp.vintage && opts_decomp.realtime>1
     preamble_txt = 'Shock decomposition';
 else
     preamble_txt = 'Historical shock decomposition';
@@ -124,7 +124,7 @@ ntotrow = nrow;
 nrow = min(ntotrow, 6);
 nfigs = ceil(ntotrow/nrow);
 labels = char(char(shock_names),'Initial values');
-if ~(screen_shocks && comp_nbr>18),
+if ~(screen_shocks && comp_nbr>18)
     screen_shocks=0;
 end
 comp_nbr0=comp_nbr;
@@ -155,7 +155,7 @@ for j=1:nvar
     a0=zeros(1,4);
     a0(3)=inf;
     a0(4)=-inf;
-    for ic=1+nrow*ncol*(jf-1):min(nrow*ncol*jf,comp_nbr),
+    for ic=1+nrow*ncol*(jf-1):min(nrow*ncol*jf,comp_nbr)
         i = ic-nrow*ncol*(jf-1);
         zz = z1(ic,:);        
         zz(2,:)=z1(end,:)-zz;
@@ -195,7 +195,7 @@ for j=1:nvar
             end
         end
     end
-    for isub=1:i,
+    for isub=1:i
         subplot(nrow,ncol,isub),
         set(gca,'ylim',a0(3:4))
     end
@@ -219,7 +219,7 @@ for j=1:nvar
     end
     
     
-    if nfigs>1,
+    if nfigs>1
         suffix = ['_detail_' int2str(jf)];
     else
         suffix = ['_detail'];
diff --git a/matlab/gsa/Morris_Measure_Groups.m b/matlab/gsa/Morris_Measure_Groups.m
index dfd37bdd1..1aa387f07 100644
--- a/matlab/gsa/Morris_Measure_Groups.m
+++ b/matlab/gsa/Morris_Measure_Groups.m
@@ -44,7 +44,7 @@ function [SAmeas, OutMatrix] = Morris_Measure_Groups(NumFact, Sample, Output, p,
 % You should have received a copy of the GNU General Public License
 % along with Dynare.  If not, see <http://www.gnu.org/licenses/>.
 
-if nargin==0,
+if nargin==0
   skipline()
   disp('[SAmeas, OutMatrix] = Morris_Measure_Groups(NumFact, Sample, Output, p, Group);')
   return
@@ -54,7 +54,7 @@ OutMatrix=[];
 if nargin < 5, Group=[]; end
 
 NumGroups = size(Group,2);
-if nargin < 4 | isempty(p),
+if nargin < 4 | isempty(p)
     p = 4;
 end
 Delt = p/(2*p-2);
@@ -88,7 +88,7 @@ for k=1:size(Output,2)
         % is partitioned in four parts, from order zero to order 4th.
         for j=1:sizea   % For each point in the trajectory i.e for each factor   
             % matrix of factor which changes
-            if NumGroups ~ 0;
+            if NumGroups ~ 0
                 AuxFind (:,1) = A(:,j);
 %                 AuxFind(find(A(:,j)),1)=1;
 %                 Pippo = sum((Group - repmat(AuxFind,1,NumGroups)),1);
@@ -122,7 +122,7 @@ for k=1:size(Output,2)
 
     % Compute Mu AbsMu and StDev
     if any(any(isnan(SAmeas)))
-      for j=1:NumFact,
+      for j=1:NumFact
         SAm = SAmeas(j,:);
         SAm = SAm(find(~isnan(SAm)));
         rr=length(SAm);
diff --git a/matlab/gsa/cumplot.m b/matlab/gsa/cumplot.m
index 128e209ac..d210c81f9 100644
--- a/matlab/gsa/cumplot.m
+++ b/matlab/gsa/cumplot.m
@@ -1,4 +1,4 @@
-function h = cumplot(x);
+function h = cumplot(x)
 %function h =cumplot(x)
 
 % Written by Marco Ratto
@@ -29,6 +29,6 @@ y=[0:n n]./n;
 h0 = stairs(x,y);
 grid on,
 
-if nargout,
+if nargout
     h=h0;
 end
diff --git a/matlab/gsa/filt_mc_.m b/matlab/gsa/filt_mc_.m
index b6c4994d8..bf37c148b 100644
--- a/matlab/gsa/filt_mc_.m
+++ b/matlab/gsa/filt_mc_.m
@@ -57,11 +57,11 @@ skipline(2)
 disp('Starting sensitivity analysis')
 disp('for the fit of EACH observed series ...')
 skipline()
-if ~options_.nograph,
+if ~options_.nograph
 disp('Deleting old SA figures...')
 a=dir([OutDir,filesep,'*.*']);
 tmp1='0';
-if options_.opt_gsa.ppost,
+if options_.opt_gsa.ppost
     tmp=['_rmse_post'];
 else
     if options_.opt_gsa.pprior
@@ -69,40 +69,40 @@ else
     else
         tmp=['_rmse_mc'];
     end
-    if options_gsa_.lik_only,
+    if options_gsa_.lik_only
         tmp1 = [tmp,'_post_SA'];
         tmp = [tmp,'_lik_SA'];
     end
 end
-for j=1:length(a),
-    if strmatch([fname_,tmp],a(j).name),
+for j=1:length(a)
+    if strmatch([fname_,tmp],a(j).name)
         disp(a(j).name)
         delete([OutDir,filesep,a(j).name])
-    end,
-    if strmatch([fname_,tmp1],a(j).name),
+    end
+    if strmatch([fname_,tmp1],a(j).name)
         disp(a(j).name)
         delete([OutDir,filesep,a(j).name])
-    end,
+    end
 end
 disp('done !')
 end
 
 nshock=estim_params_.nvx + estim_params_.nvn + estim_params_.ncx + estim_params_.ncn;
 npar=estim_params_.np;
-if ~isempty(options_.mode_file),
-    load(options_.mode_file,'xparam1'),
+if ~isempty(options_.mode_file)
+    load(options_.mode_file,'xparam1')
 end
-if options_.opt_gsa.ppost,
+if options_.opt_gsa.ppost
     c=load([fname_,'_mean.mat'],'xparam1');
     xparam1_mean=c.xparam1;
     clear c
-elseif ~isempty(options_.mode_file) && exist([fname_,'_mean.mat'])==2,
+elseif ~isempty(options_.mode_file) && exist([fname_,'_mean.mat'])==2
     c=load([fname_,'_mean.mat'],'xparam1');
     xparam1_mean=c.xparam1;
     clear c
 end
 
-if options_.opt_gsa.ppost,
+if options_.opt_gsa.ppost
     fnamtmp=[fname_,'_post'];
     DirectoryName = CheckPath('metropolis',M_.dname);
 else
@@ -114,9 +114,9 @@ else
         DirectoryName = CheckPath(['gsa' filesep 'mc'],M_.dname);
     end
 end
-if loadSA,
+if loadSA
     tmplist =load([OutDir,filesep,fnamtmp, '.mat'],'vvarvecm');
-    if isempty(fieldnames(tmplist)),
+    if isempty(fieldnames(tmplist))
         disp('WARNING: cannot load results since the list of variables used is not present in the mat file')
         loadSA=0;
     elseif ~isequal(tmplist.vvarvecm,vvarvecm)
@@ -124,7 +124,7 @@ if loadSA,
         loadSA=0;
     end
 end
-if ~loadSA,
+if ~loadSA
     if exist('xparam1','var')
         M_ = set_all_parameters(xparam1,estim_params_,M_);
         ys_mode=steady_(M_,options_,oo_);
@@ -147,7 +147,7 @@ if ~loadSA,
     filfilt = dir([DirectoryName filesep M_.fname '_filter_step_ahead*.mat']);
     temp_smooth_file_list = dir([DirectoryName filesep M_.fname '_smooth*.mat']);
     jfile=0;
-    for j=1:length(temp_smooth_file_list),
+    for j=1:length(temp_smooth_file_list)
         if isempty(strfind(temp_smooth_file_list(j).name,'smoothed')),
             jfile=jfile+1;
             filsmooth(jfile)=temp_smooth_file_list(j);
@@ -158,7 +158,7 @@ if ~loadSA,
     x=[];
     logpo2=[];
     sto_ys=[];
-    for j=1:length(filparam),
+    for j=1:length(filparam)
         %load([DirectoryName filesep M_.fname '_param',int2str(j),'.mat']);
         if isempty(strmatch([M_.fname '_param_irf'],filparam(j).name))
             load([DirectoryName filesep filparam(j).name]);
@@ -173,7 +173,7 @@ if ~loadSA,
     if options_.opt_gsa.ppost || (options_.opt_gsa.ppost==0 && options_.opt_gsa.lik_only==0)
         skipline()
         disp('Computing RMSE''s...')
-        for i=1:size(vvarvecm,1),
+        for i=1:size(vvarvecm,1)
             vj=deblank(vvarvecm(i,:));
             
             jxj(i) = strmatch(vj,lgy_(dr_.order_var,:),'exact');
@@ -189,7 +189,7 @@ if ~loadSA,
         end
         y0=-yss;
         nbb=0;
-        for j=1:length(filfilt),
+        for j=1:length(filfilt)
             load([DirectoryName filesep M_.fname '_filter_step_ahead',num2str(j),'.mat']);
             nb = size(stock,4);
             y0(:,:,nbb+1:nbb+nb)=y0(:,:,nbb+1:nbb+nb)+reshape(stock(1,js,1:gend,:),[length(js) gend nb]);
@@ -198,7 +198,7 @@ if ~loadSA,
         end
         yobs=-yss;
         nbb=0;
-        for j=1:length(filupdate),
+        for j=1:length(filupdate)
             load([DirectoryName filesep M_.fname '_update',num2str(j),'.mat']);
             nb = size(stock,3);
             yobs(:,:,nbb+1:nbb+nb)=yobs(:,:,nbb+1:nbb+nb)+reshape(stock(js,1:gend,:),[length(js) gend nb]);
@@ -208,7 +208,7 @@ if ~loadSA,
         y0M=mean(y0,2);
         rmse_MC=zeros(nruns,length(js));
         r2_MC=zeros(nruns,length(js));
-        for j=1:nruns,
+        for j=1:nruns
             rmse_MC(j,:) = sqrt(mean((yobs(:,istart:end,j)'-y0(:,istart:end,j)').^2));
             r2_MC(j,:) = 1-mean((yobs(:,istart:end,j)'-y0(:,istart:end,j)').^2)./mean((yobs(:,istart:end,j)').^2);
         end
@@ -222,7 +222,7 @@ if ~loadSA,
         end
         clear stock_filter;
     end
-    for j=1:nruns,
+    for j=1:nruns
         lnprior(j,1) = priordens(x(j,:)',bayestopt_.pshape,bayestopt_.p6,bayestopt_.p7,bayestopt_.p3,bayestopt_.p4);
     end
     likelihood=logpo2(:)-lnprior(:);
@@ -338,12 +338,12 @@ if ~options_.opt_gsa.ppost && options_.opt_gsa.lik_only
     mcf_analysis(x, ilik(1:nfilt), ilik(nfilt+1:end), options_mcf, options_);
     
 else
-    if options_.opt_gsa.ppost,
+    if options_.opt_gsa.ppost
         rmse_txt=rmse_pmean;
         r2_txt=r2_pmean;
     else
-        if options_.opt_gsa.pprior || ~exist('rmse_pmean'),
-            if exist('rmse_mode'),
+        if options_.opt_gsa.pprior || ~exist('rmse_pmean')
+            if exist('rmse_mode')
                 rmse_txt=rmse_mode;
                 r2_txt=r2_mode;
             else
@@ -356,28 +356,28 @@ else
             r2_txt=r2_pmean;
         end
     end
-    for i=1:size(vvarvecm,1),
+    for i=1:size(vvarvecm,1)
         [dum, ixx(:,i)]=sort(rmse_MC(:,i));
     end
     PP=ones(npar+nshock,size(vvarvecm,1));
     PPV=ones(size(vvarvecm,1),size(vvarvecm,1),npar+nshock);
     SS=zeros(npar+nshock,size(vvarvecm,1));
-    for j=1:npar+nshock,
-        for i=1:size(vvarvecm,1),
+    for j=1:npar+nshock
+        for i=1:size(vvarvecm,1)
             [H,P,KSSTAT] = smirnov(x(ixx(nfilt0(i)+1:end,i),j),x(ixx(1:nfilt0(i),i),j), alpha);
             [H1,P1,KSSTAT1] = smirnov(x(ixx(nfilt0(i)+1:end,i),j),x(ixx(1:nfilt0(i),i),j),alpha,1);
             [H2,P2,KSSTAT2] = smirnov(x(ixx(nfilt0(i)+1:end,i),j),x(ixx(1:nfilt0(i),i),j),alpha,-1);
-            if H1 & H2==0,
+            if H1 & H2==0
                 SS(j,i)=1;
-            elseif H1==0,
+            elseif H1==0
                 SS(j,i)=-1;
             else
                 SS(j,i)=0;
             end
             PP(j,i)=P;
         end
-        for i=1:size(vvarvecm,1),
-            for l=1:size(vvarvecm,1),
+        for i=1:size(vvarvecm,1)
+            for l=1:size(vvarvecm,1)
                 if l~=i && PP(j,i)<alpha && PP(j,l)<alpha
                     [H,P,KSSTAT] = smirnov(x(ixx(1:nfilt0(i),i),j),x(ixx(1:nfilt0(l),l),j), alpha);
                     %[H1,P1,KSSTAT1] = smirnov(x(ixx(1:nfilt0(i),i),j),x(:,j), alpha);
@@ -393,9 +393,9 @@ else
             end
         end
     end
-    if ~options_.nograph,
+    if ~options_.nograph
         ifig=0;
-        for i=1:size(vvarvecm,1),
+        for i=1:size(vvarvecm,1)
             if options_.opt_gsa.ppost
                 temp_name='RMSE Posterior: Log Prior';
             else
@@ -405,7 +405,7 @@ else
                     temp_name='RMSE MC: Log Prior';
                 end
             end
-            if mod(i,9)==1,
+            if mod(i,9)==1
                 ifig=ifig+1;
                 hh=dyn_figure(options_.nodisplay,'name',[temp_name,' ',int2str(ifig)]);
             end
@@ -443,7 +443,7 @@ else
             end
         end
         ifig=0;
-        for i=1:size(vvarvecm,1),
+        for i=1:size(vvarvecm,1)
             if options_.opt_gsa.ppost
                 temp_name='RMSE Posterior: Log Likelihood';
             else
@@ -453,7 +453,7 @@ else
                     temp_name='RMSE MC: Log Likelihood';
                 end
             end
-            if mod(i,9)==1,
+            if mod(i,9)==1
                 ifig=ifig+1;
                 hh = dyn_figure(options_.nodisplay,'Name',[temp_name,' ',int2str(ifig)]);
             end
@@ -465,7 +465,7 @@ else
             h=cumplot(likelihood(ixx(nfilt0(i)+1:end,i)));
             set(h,'color','red','linewidth',2)
             title(vvarvecm(i,:),'interpreter','none')
-            if options_.opt_gsa.ppost==0,
+            if options_.opt_gsa.ppost==0
                 set(gca,'xlim',[min( likelihood(ixx(1:nfilt0(i),i)) ) max( likelihood(ixx(1:nfilt0(i),i)) )])
             end
             if mod(i,9)==0 || i==size(vvarvecm,1)
@@ -494,7 +494,7 @@ else
             end
         end
         ifig=0;
-        for i=1:size(vvarvecm,1),
+        for i=1:size(vvarvecm,1)
             if options_.opt_gsa.ppost
                 temp_name='RMSE Posterior: Log Posterior';
             else
@@ -504,7 +504,7 @@ else
                     temp_name='RMSE MC: Log Posterior';
                 end
             end
-            if mod(i,9)==1,
+            if mod(i,9)==1
                 ifig=ifig+1;
                 hh = dyn_figure(options_.nodisplay,'Name',[temp_name,' ',int2str(ifig)]);
             end
@@ -516,7 +516,7 @@ else
             h=cumplot(logpo2(ixx(nfilt0(i)+1:end,i)));
             set(h,'color','red','linewidth',2)
             title(vvarvecm(i,:),'interpreter','none')
-            if options_.opt_gsa.ppost==0,
+            if options_.opt_gsa.ppost==0
                 set(gca,'xlim',[min( logpo2(ixx(1:nfilt0(i),i)) ) max( logpo2(ixx(1:nfilt0(i),i)) )])
             end
             if mod(i,9)==0 || i==size(vvarvecm,1)
@@ -594,7 +594,7 @@ else
     skipline(2)
     disp('RMSE ranges after filtering:')
     title_string='RMSE ranges after filtering:';
-    if options_.opt_gsa.ppost==0 && options_.opt_gsa.pprior,
+    if options_.opt_gsa.ppost==0 && options_.opt_gsa.pprior
         headers=strvcat('Variable','min','max','min','max','posterior mode');
         headers_tex=strvcat('\text{Variable}','\text{min}','\text{max}','\text{min}','\text{max}','\text{posterior mode}');
     else
@@ -602,7 +602,7 @@ else
         headers_tex=strvcat('\text{Variable}','\text{min}','\text{max}','\text{min}','\text{max}','\text{posterior mean}');
     end
     data_mat=NaN(size(vvarvecm,1),5);
-    for j=1:size(vvarvecm,1),
+    for j=1:size(vvarvecm,1)
         data_mat(j,:)=[min(rmse_MC(ixx(1:nfilt0(j),j),j)) ...
             max(rmse_MC(ixx(1:nfilt0(j),j),j))  ...
             min(rmse_MC(ixx(nfilt0(j)+1:end,j),j)) ...
@@ -632,14 +632,14 @@ else
     value_format  = sprintf('%%%d.%df',val_width,val_precis);
     header_string_format  = sprintf('%%%ds',val_width);
     
-    if options_.opt_gsa.ppost==0 && options_.opt_gsa.pprior,
+    if options_.opt_gsa.ppost==0 && options_.opt_gsa.pprior
         optional_header=sprintf([label_format_leftbound,header_string_format,header_string_format,header_string_format,header_string_format],'','',['best ',num2str(pfilt*100),'% filtered'],'','remaining 90%');
     else
         optional_header=sprintf([label_format_leftbound,header_string_format,header_string_format,header_string_format,header_string_format],'','','best  filtered','','remaining');
     end
     dyntable(options_,title_string,headers,vvarvecm,data_mat, 0, val_width, val_precis,optional_header);
     if options_.TeX
-        if options_.opt_gsa.ppost==0 && options_.opt_gsa.pprior,
+        if options_.opt_gsa.ppost==0 && options_.opt_gsa.pprior
             optional_header={[' & \multicolumn{2}{c}{best ',num2str(pfilt*100),' filtered} & \multicolumn{2}{c}{remaining 90\%}\\']};
         else
             optional_header={[' & \multicolumn{2}{c}{best filtered} & \multicolumn{2}{c}{remaining}\\']};
@@ -668,7 +668,7 @@ else
     skipline()
     disp('R2 ranges after filtering:')
     title_string='R2 ranges after filtering:';
-    if options_.opt_gsa.ppost==0 && options_.opt_gsa.pprior,
+    if options_.opt_gsa.ppost==0 && options_.opt_gsa.pprior
         headers=strvcat('Variable','min','max','min','max','posterior mode');
         headers_tex=strvcat('\text{Variable}','\text{min}','\text{max}','\text{min}','\text{max}','\text{posterior mode}');
     else
@@ -676,7 +676,7 @@ else
         headers_tex=strvcat('\text{Variable}','\text{min}','\text{max}','\text{min}','\text{max}','\text{posterior mean}');
     end
     data_mat=NaN(size(vvarvecm,1),5);
-    for j=1:size(vvarvecm,1),
+    for j=1:size(vvarvecm,1)
         data_mat(j,:)=[min(r2_MC(ixx(1:nfilt0(j),j),j)) ...
             max(r2_MC(ixx(1:nfilt0(j),j),j))  ...
             min(r2_MC(ixx(nfilt0(j)+1:end,j),j)) ...
@@ -706,14 +706,14 @@ else
     value_format  = sprintf('%%%d.%df',val_width,val_precis);
     header_string_format  = sprintf('%%%ds',val_width);
     
-    if options_.opt_gsa.ppost==0 && options_.opt_gsa.pprior,
+    if options_.opt_gsa.ppost==0 && options_.opt_gsa.pprior
         optional_header=sprintf([label_format_leftbound,header_string_format,header_string_format,header_string_format,header_string_format],'','',['best ',num2str(pfilt*100),'% filtered'],'','remaining 90%');
     else
         optional_header=sprintf([label_format_leftbound,header_string_format,header_string_format,header_string_format,header_string_format],'','','best  filtered','','remaining');
     end
     dyntable(options_,title_string,headers,vvarvecm,data_mat, 0, val_width, val_precis,optional_header);
     if options_.TeX
-        if options_.opt_gsa.ppost==0 && options_.opt_gsa.pprior,
+        if options_.opt_gsa.ppost==0 && options_.opt_gsa.pprior
             optional_header={[' & \multicolumn{2}{c}{best ',num2str(pfilt*100),' filtered} & \multicolumn{2}{c}{remaining 90\%}\\']};
         else
             optional_header={[' & \multicolumn{2}{c}{best filtered} & \multicolumn{2}{c}{remaining}\\']};
@@ -724,13 +724,13 @@ else
     
     %%%%  R2 table
     SP=zeros(npar+nshock,size(vvarvecm,1));
-    for j=1:size(vvarvecm,1),
+    for j=1:size(vvarvecm,1)
         ns=find(PP(:,j)<alpha);
         SP(ns,j)=ones(size(ns));
         SS(:,j)=SS(:,j).*SP(:,j);
     end
     
-    for j=1:npar+nshock, %estim_params_.np,
+    for j=1:npar+nshock %estim_params_.np,
         nsp(j)=length(find(SP(j,:)));
     end
     snam0=param_names(find(nsp==0),:);
@@ -783,7 +783,7 @@ else
         options_mcf.param_names_tex = param_names_tex;
         options_mcf.fname_ = fname_;
         options_mcf.OutputDirectoryName = OutDir;
-        for iy=1:size(vvarvecm,1),
+        for iy=1:size(vvarvecm,1)
             options_mcf.amcf_name = [asname '_' deblank(vvarvecm(iy,:)) '_map' ];
             options_mcf.amcf_title = [atitle ' ' deblank(vvarvecm(iy,:))];
             options_mcf.beha_title = ['better fit of ' deblank(vvarvecm(iy,:))];
@@ -791,21 +791,21 @@ else
             options_mcf.title = ['the fit of ' deblank(vvarvecm(iy,:))];
             mcf_analysis(x, ixx(1:nfilt0(iy),iy), ixx(nfilt0(iy)+1:end,iy), options_mcf, options_);
         end
-        for iy=1:size(vvarvecm,1),
+        for iy=1:size(vvarvecm,1)
             ipar = find(any(squeeze(PPV(iy,:,:))<alpha));
-            for ix=1:ceil(length(ipar)/5),
+            for ix=1:ceil(length(ipar)/5)
                 hh = dyn_figure(options_.nodisplay,'name',[temp_name,' observed variable ',deblank(vvarvecm(iy,:))]);
-                for j=1+5*(ix-1):min(length(ipar),5*ix),
+                for j=1+5*(ix-1):min(length(ipar),5*ix)
                     subplot(2,3,j-5*(ix-1))
                     %h0=cumplot(x(:,nsnam(j)+nshock));
                     h0=cumplot(x(:,ipar(j)));
                     set(h0,'color',[0 0 0])
                     hold on,
                     iobs=find(squeeze(PPV(iy,:,ipar(j)))<alpha);
-                    for i=1:size(vvarvecm,1),
+                    for i=1:size(vvarvecm,1)
                         %h0=cumplot(x(ixx(1:nfilt,np(i)),nsnam(j)+nshock));
                         %                 h0=cumplot(x(ixx(1:nfilt0(np(i)),np(i)),nsnam(j)));
-                        if any(iobs==i) || i==iy,
+                        if any(iobs==i) || i==iy
                             h0=cumplot(x(ixx(1:nfilt0(i),i),ipar(j)));
                             if ~isoctave
                                 hcmenu = uicontextmenu;
@@ -858,9 +858,9 @@ else
         end
         
         % now I plot by individual parameters
-        for ix=1:ceil(length(nsnam)/5),
+        for ix=1:ceil(length(nsnam)/5)
             hh = dyn_figure(options_.nodisplay,'name',[temp_name,' estimated params and shocks ',int2str(ix)]);
-            for j=1+5*(ix-1):min(size(snam2,1),5*ix),
+            for j=1+5*(ix-1):min(size(snam2,1),5*ix)
                 subplot(2,3,j-5*(ix-1))
                 %h0=cumplot(x(:,nsnam(j)+nshock));
                 h0=cumplot(x(:,nsnam(j)));
@@ -869,10 +869,10 @@ else
                 npx=find(SP(nsnam(j),:)==0);
                 %a0=jet(nsp(nsnam(j)));
                 %             a0=a00(np,:);
-                for i=1:size(vvarvecm,1),
+                for i=1:size(vvarvecm,1)
                     %h0=cumplot(x(ixx(1:nfilt,np(i)),nsnam(j)+nshock));
                     %                 h0=cumplot(x(ixx(1:nfilt0(np(i)),np(i)),nsnam(j)));
-                    if any(npx==i),
+                    if any(npx==i)
                         h0=cumplot(x(ixx(1:nfilt0(i),i),nsnam(j))*NaN);
                     else
                         h0=cumplot(x(ixx(1:nfilt0(i),i),nsnam(j)));
diff --git a/matlab/gsa/gsa_plotmatrix.m b/matlab/gsa/gsa_plotmatrix.m
index 9c9aee99f..7b6e44ded 100644
--- a/matlab/gsa/gsa_plotmatrix.m
+++ b/matlab/gsa/gsa_plotmatrix.m
@@ -65,18 +65,18 @@ switch type
         
 end
 
-if isempty(x),
+if isempty(x)
     disp('Empty parameter set!')
     return
 end
 
-for j=1:length(varargin),
+for j=1:length(varargin)
     jcol(j)=strmatch(varargin{j},bayestopt_.name,'exact');
 end
 
 [H,AX,BigA,P,PAx]=plotmatrix(x(:,jcol));
 
-for j=1:length(varargin),
+for j=1:length(varargin)
     %      axes(AX(1,j)), title(varargin{j})
     %      axes(AX(j,1)), ylabel(varargin{j})
     %      set(AX(1,j),'title',varargin{j}),
@@ -84,15 +84,15 @@ for j=1:length(varargin),
     set(get(AX(end,j),'xlabel'),'string',varargin{j})
 end
 
-if options_.opt_gsa.pprior==0,
+if options_.opt_gsa.pprior==0
     xparam1=xparam1(jcol);
-    for j=1:length(varargin),
-        for i=1:j-1,
-            axes(AX(j,i)),
+    for j=1:length(varargin)
+        for i=1:j-1
+            axes(AX(j,i))
             hold on, plot(xparam1(i),xparam1(j),'*r')
         end
-        for i=j+1:length(varargin),
-            axes(AX(j,i)),
+        for i=j+1:length(varargin)
+            axes(AX(j,i))
             hold on, plot(xparam1(i),xparam1(j),'*r')
         end
     end
diff --git a/matlab/gsa/gsa_skewness.m b/matlab/gsa/gsa_skewness.m
index b5af1c6ce..24ced8013 100644
--- a/matlab/gsa/gsa_skewness.m
+++ b/matlab/gsa/gsa_skewness.m
@@ -1,4 +1,4 @@
-function s=gsa_skewness(y),
+function s=gsa_skewness(y)
 
 % Written by Marco Ratto
 % Joint Research Centre, The European Commission,
diff --git a/matlab/gsa/gsa_speed.m b/matlab/gsa/gsa_speed.m
index 9fce2e94b..fbbf58e74 100644
--- a/matlab/gsa/gsa_speed.m
+++ b/matlab/gsa/gsa_speed.m
@@ -1,4 +1,4 @@
-function [tadj, iff] = gsa_speed(A,B,mf,p),
+function [tadj, iff] = gsa_speed(A,B,mf,p)
 % [tadj, iff] = gsa_speed(A,B,mf,p),
 %
 % Written by Marco Ratto
@@ -33,7 +33,7 @@ tadj=iff;
 disp('Computing speed of adjustement ...')
 h = dyn_waitbar(0,'Speed of adjustement...');
 
-for i=1:nrun,
+for i=1:nrun
   irf=zeros(nvar,nshock);
   a=squeeze(A(:,:,i));
   b=squeeze(B(:,:,i));
diff --git a/matlab/gsa/log_trans_.m b/matlab/gsa/log_trans_.m
index d1a028e65..f31b434d3 100644
--- a/matlab/gsa/log_trans_.m
+++ b/matlab/gsa/log_trans_.m
@@ -22,13 +22,13 @@ function [yy, xdir, isig, lam]=log_trans_(y0,xdir0,isig,lam)
 % You should have received a copy of the GNU General Public License
 % along with Dynare.  If not, see <http://www.gnu.org/licenses/>.
 
-if nargin==4,
+if nargin==4
     % inverse transformation
     yy = (exp(y0)-lam)*isig;
     return
 end
 
-if nargin==1,
+if nargin==1
   xdir0='';
 end
 f=@(lam,y)gsa_skewness(log(y+lam));
@@ -39,8 +39,9 @@ if ~(max(y0)<0 | min(y0)>0)
     y0=-y0;
   end
   n=hist(y0,10);
-  if n(1)>20*n(end),
-    try lam=fzero(f,[-min(y0)+10*eps -min(y0)+abs(median(y0))],[],y0);
+  if n(1)>20*n(end)
+    try 
+        lam=fzero(f,[-min(y0)+10*eps -min(y0)+abs(median(y0))],[],y0);
     catch
       yl(1)=f(-min(y0)+10*eps,y0);
       yl(2)=f(-min(y0)+abs(median(y0)),y0);
@@ -68,7 +69,8 @@ else
     %yy=log(y0);
     xdir=[xdir0,'_log'];
   end
-  try lam=fzero(f,[-min(y0)+10*eps -min(y0)+median(y0)],[],y0);
+  try 
+      lam=fzero(f,[-min(y0)+10*eps -min(y0)+median(y0)],[],y0);
   catch
     yl(1)=f(-min(y0)+10*eps,y0);
       yl(2)=f(-min(y0)+abs(median(y0)),y0);
diff --git a/matlab/gsa/map_calibration.m b/matlab/gsa/map_calibration.m
index 712d4572f..8a1729f0f 100644
--- a/matlab/gsa/map_calibration.m
+++ b/matlab/gsa/map_calibration.m
@@ -58,10 +58,10 @@ options_mcf.OutputDirectoryName = OutputDirectoryName;
 skipline()
 disp('Sensitivity analysis for calibration criteria')
 
-if DynareOptions.opt_gsa.ppost,
+if DynareOptions.opt_gsa.ppost
     filetoload=dir([Model.dname filesep 'metropolis' filesep fname_ '_param_irf*.mat']);
     lpmat=[];
-    for j=1:length(filetoload),
+    for j=1:length(filetoload)
         load([Model.dname filesep 'metropolis' filesep fname_ '_param_irf',int2str(j),'.mat'])
         lpmat = [lpmat; stock];
         clear stock
@@ -89,34 +89,34 @@ nbr_moment_restrictions = size(DynareOptions.endogenous_prior_restrictions.momen
 
 if init
     mat_irf=cell(nbr_irf_restrictions,1);
-    for ij=1:nbr_irf_restrictions,
+    for ij=1:nbr_irf_restrictions
         mat_irf{ij}=NaN(Nsam,length(DynareOptions.endogenous_prior_restrictions.irf{ij,3}));
     end
     
     mat_moment=cell(nbr_moment_restrictions,1);
-    for ij=1:nbr_moment_restrictions,
+    for ij=1:nbr_moment_restrictions
         mat_moment{ij}=NaN(Nsam,length(DynareOptions.endogenous_prior_restrictions.moment{ij,3}));
     end
     
     irestrictions = [1:Nsam];
     h = dyn_waitbar(0,'Please wait...');
-    for j=1:Nsam,
+    for j=1:Nsam
         Model = set_all_parameters(lpmat(j,:)',EstimatedParameters,Model);
-        if nbr_moment_restrictions,
+        if nbr_moment_restrictions
             [Tt,Rr,SteadyState,info,Model,DynareOptions,DynareResults] = dynare_resolve(Model,DynareOptions,DynareResults);
         else
             [Tt,Rr,SteadyState,info,Model,DynareOptions,DynareResults] = dynare_resolve(Model,DynareOptions,DynareResults,'restrict');
         end
-        if info(1)==0,
+        if info(1)==0
             [info, info_irf, info_moment, data_irf, data_moment]=endogenous_prior_restrictions(Tt,Rr,Model,DynareOptions,DynareResults);
             if ~isempty(info_irf)
-                for ij=1:nbr_irf_restrictions,
+                for ij=1:nbr_irf_restrictions
                     mat_irf{ij}(j,:)=data_irf{ij}(:,2)';
                 end
                 indx_irf(j,:)=info_irf(:,1);
             end
             if ~isempty(info_moment)
-                for ij=1:nbr_moment_restrictions,
+                for ij=1:nbr_moment_restrictions
                     mat_moment{ij}(j,:)=data_moment{ij}(:,2)';
                 end
                 indx_moment(j,:)=info_moment(:,1);
@@ -136,31 +136,31 @@ if init
 else
     load([OutputDirectoryName,filesep,fname_,'_',type,'_restrictions'],'xmat','mat_irf','mat_moment','irestrictions','indx_irf','indx_moment','endo_prior_restrictions');
 end
-if ~isempty(indx_irf),
+if ~isempty(indx_irf)
     skipline()
     disp('Deleting old IRF calibration plots ...')
     a=dir([OutputDirectoryName,filesep,fname_,'_',type,'_irf_calib*.eps']);
-    for j=1:length(a),
+    for j=1:length(a)
         delete([OutputDirectoryName,filesep,a(j).name]);
     end
     a=dir([OutputDirectoryName,filesep,fname_,'_',type,'_irf_calib*.fig']);
-    for j=1:length(a),
+    for j=1:length(a)
         delete([OutputDirectoryName,filesep,a(j).name]);
     end
     a=dir([OutputDirectoryName,filesep,fname_,'_',type,'_irf_calib*.pdf']);
-    for j=1:length(a),
+    for j=1:length(a)
         delete([OutputDirectoryName,filesep,a(j).name]);
     end
     a=dir([OutputDirectoryName,filesep,fname_,'_',type,'_irf_restrictions.eps']);
-    for j=1:length(a),
+    for j=1:length(a)
         delete([OutputDirectoryName,filesep,a(j).name]);
     end
     a=dir([OutputDirectoryName,filesep,fname_,'_',type,'_irf_restrictions.fig']);
-    for j=1:length(a),
+    for j=1:length(a)
         delete([OutputDirectoryName,filesep,a(j).name]);
     end
     a=dir([OutputDirectoryName,filesep,fname_,'_',type,'_irf_restrictions.pdf']);
-    for j=1:length(a),
+    for j=1:length(a)
         delete([OutputDirectoryName,filesep,a(j).name]);
     end
     disp('done !')
@@ -190,19 +190,19 @@ if ~isempty(indx_irf),
     iplot_indx = ones(size(plot_indx));
     
     indx_irf = indx_irf(irestrictions,:);
-    if ~DynareOptions.nograph,
+    if ~DynareOptions.nograph
         h1=dyn_figure(DynareOptions.nodisplay,'name',[type ' evaluation of irf restrictions']);
         nrow=ceil(sqrt(nbr_irf_couples));
         ncol=nrow;
-        if nrow*(nrow-1)>nbr_irf_couples,
+        if nrow*(nrow-1)>nbr_irf_couples
             ncol=nrow-1;
         end
     end
-    for ij=1:nbr_irf_restrictions,
+    for ij=1:nbr_irf_restrictions
         mat_irf{ij}=mat_irf{ij}(irestrictions,:);
         irf_matrix{plot_indx(ij)} = [irf_matrix{plot_indx(ij)} mat_irf{ij}];
         indx_irf_matrix(:,plot_indx(ij)) = indx_irf_matrix(:,plot_indx(ij)) + indx_irf(:,ij);
-        for ik=1:size(mat_irf{ij},2),
+        for ik=1:size(mat_irf{ij},2)
             [Mean,Median,Var,HPD,Distrib] = ...
                 posterior_moments(mat_irf{ij}(:,ik),0,DynareOptions.mh_conf_sig);
             irf_mean{plot_indx(ij)} = [irf_mean{plot_indx(ij)}; Mean];
@@ -213,12 +213,12 @@ if ~isempty(indx_irf),
         end
         leg = num2str(endo_prior_restrictions.irf{ij,3}(1));
         aleg = num2str(endo_prior_restrictions.irf{ij,3}(1));
-        if size(mat_irf{ij},2)>1,
+        if size(mat_irf{ij},2)>1
             leg = [leg,':' ,num2str(endo_prior_restrictions.irf{ij,3}(end))];
             aleg = [aleg,'-' ,num2str(endo_prior_restrictions.irf{ij,3}(end))];
             iplot_indx(ij)=0;
         end
-        if ~DynareOptions.nograph && length(time_matrix{plot_indx(ij)})==1,
+        if ~DynareOptions.nograph && length(time_matrix{plot_indx(ij)})==1
             set(0,'currentfigure',h1),
             subplot(nrow,ncol, plot_indx(ij)),
             hc = cumplot(mat_irf{ij}(:,ik));
@@ -267,9 +267,9 @@ if ~isempty(indx_irf),
         %             stab_map_1(xmat, indx1, indx2, aname, 1, indplot, OutputDirectoryName,[],atitle);
         %         end
     end
-    for ij=1:nbr_irf_couples,
-        if length(time_matrix{ij})>1,
-            if ~DynareOptions.nograph,
+    for ij=1:nbr_irf_couples
+        if length(time_matrix{ij})>1
+            if ~DynareOptions.nograph
                 set(0,'currentfigure',h1);
                 subplot(nrow,ncol, ij)
                 itmp = (find(plot_indx==ij));
@@ -277,7 +277,7 @@ if ~isempty(indx_irf),
                 a=axis;
                 delete(htmp);
                 tmp=[];
-                for ir=1:length(itmp),
+                for ir=1:length(itmp)
                     for it=1:length(endo_prior_restrictions.irf{itmp(ir),3})
                         temp_index = find(time_matrix{ij}==endo_prior_restrictions.irf{itmp(ir),3}(it));
                         tmp(temp_index,:) = endo_prior_restrictions.irf{itmp(ir),4};
@@ -293,14 +293,14 @@ if ~isempty(indx_irf),
                 plot(time_matrix{ij},irf_median{ij},'k','linewidth',2)
                 plot(time_matrix{ij},[irf_distrib{ij}],'k-')
                 plot(a(1:2),[0 0],'r')
-                hold off,
+                hold off
                 axis([max(1,a(1)) a(2:4)])
-                box on,
+                box on
                 %set(gca,'xtick',sort(time_matrix{ij}))
                 itmp = min(itmp);
                 title([endo_prior_restrictions.irf{itmp,1},' vs ',endo_prior_restrictions.irf{itmp,2}],'interpreter','none'),
             end
-            if any(iplot_indx.*plot_indx==ij),
+            if any(iplot_indx.*plot_indx==ij)
                 % MCF of the couples with logical AND
                 itmp = min(find(plot_indx==ij));
                 indx1 = find(indx_irf_matrix(:,ij)==0);
@@ -324,7 +324,7 @@ if ~isempty(indx_irf),
             end
         end
     end
-    if ~DynareOptions.nograph,
+    if ~DynareOptions.nograph
         dyn_saveas(h1,[OutputDirectoryName,filesep,fname_,'_',type,'_irf_restrictions'],DynareOptions.nodisplay,DynareOptions.graph_format);
         create_TeX_loader(DynareOptions,[OutputDirectoryName,filesep,fname_,'_',type,'_irf_restrictions'],[type ' evaluation of irf restrictions'],'irf_restrictions',type,DynareOptions.figures.textwidth*min(ij/ncol,1))
     end
@@ -335,27 +335,27 @@ if ~isempty(indx_moment)
     skipline()
     disp('Deleting old MOMENT calibration plots ...')
     a=dir([OutputDirectoryName,filesep,fname_,'_',type,'_moment_calib*.eps']);
-    for j=1:length(a),
+    for j=1:length(a)
         delete([OutputDirectoryName,filesep,a(j).name]);
     end
     a=dir([OutputDirectoryName,filesep,fname_,'_',type,'_moment_calib*.fig']);
-    for j=1:length(a),
+    for j=1:length(a)
         delete([OutputDirectoryName,filesep,a(j).name]);
     end
     a=dir([OutputDirectoryName,filesep,fname_,'_',type,'_moment_calib*.pdf']);
-    for j=1:length(a),
+    for j=1:length(a)
         delete([OutputDirectoryName,filesep,a(j).name]);
     end
     a=dir([OutputDirectoryName,filesep,fname_,'_',type,'_moment_restrictions.eps']);
-    for j=1:length(a),
+    for j=1:length(a)
         delete([OutputDirectoryName,filesep,a(j).name]);
     end
     a=dir([OutputDirectoryName,filesep,fname_,'_',type,'_moment_restrictions.fig']);
-    for j=1:length(a),
+    for j=1:length(a)
         delete([OutputDirectoryName,filesep,a(j).name]);
     end
     a=dir([OutputDirectoryName,filesep,fname_,'_',type,'_moment_restrictions.pdf']);
-    for j=1:length(a),
+    for j=1:length(a)
         delete([OutputDirectoryName,filesep,a(j).name]);
     end
     disp('done !')
@@ -404,20 +404,20 @@ if ~isempty(indx_moment)
     iplot_indx = ones(size(plot_indx));
     
     indx_moment = indx_moment(irestrictions,:);
-    if ~DynareOptions.nograph,
+    if ~DynareOptions.nograph
         h2=dyn_figure(DynareOptions.nodisplay,'name',[type ' evaluation of moment restrictions']);
         nrow=ceil(sqrt(nbr_moment_couples));
         ncol=nrow;
-        if nrow*(nrow-1)>nbr_moment_couples,
+        if nrow*(nrow-1)>nbr_moment_couples
             ncol=nrow-1;
         end
     end
     
-    for ij=1:nbr_moment_restrictions,
+    for ij=1:nbr_moment_restrictions
         mat_moment{ij}=mat_moment{ij}(irestrictions,:);
         moment_matrix{plot_indx(ij)} = [moment_matrix{plot_indx(ij)} mat_moment{ij}];
         indx_moment_matrix(:,plot_indx(ij)) = indx_moment_matrix(:,plot_indx(ij)) + indx_moment(:,ij);
-        for ik=1:size(mat_moment{ij},2),
+        for ik=1:size(mat_moment{ij},2)
             [Mean,Median,Var,HPD,Distrib] = ...
                 posterior_moments(mat_moment{ij}(:,ik),0,DynareOptions.mh_conf_sig);
             moment_mean{plot_indx(ij)} = [moment_mean{plot_indx(ij)}; Mean];
@@ -428,12 +428,12 @@ if ~isempty(indx_moment)
         end
         leg = num2str(endo_prior_restrictions.moment{ij,3}(1));
         aleg = num2str(endo_prior_restrictions.moment{ij,3}(1));
-        if size(mat_moment{ij},2)>1,
+        if size(mat_moment{ij},2)>1
             leg = [leg,':' ,num2str(endo_prior_restrictions.moment{ij,3}(end))];
             aleg = [aleg,'_' ,num2str(endo_prior_restrictions.moment{ij,3}(end))];
             iplot_indx(ij)=0;
         end
-        if ~DynareOptions.nograph && length(time_matrix{plot_indx(ij)})==1,
+        if ~DynareOptions.nograph && length(time_matrix{plot_indx(ij)})==1
             set(0,'currentfigure',h2);
             subplot(nrow,ncol,plot_indx(ij)),
             hc = cumplot(mat_moment{ij}(:,ik));
@@ -443,10 +443,10 @@ if ~isempty(indx_moment)
             x2val=min(endo_prior_restrictions.moment{ij,4}(2),a(2));
             hp = patch([x1val x2val x2val x1val],a([3 3 4 4]),'b');
             set(hp,'FaceColor', [0.7 0.8 1])
-            hold all,
+            hold all
             hc = cumplot(mat_moment{ij}(:,ik));
             set(hc,'color','k','linewidth',2)
-            hold off,
+            hold off
             title([endo_prior_restrictions.moment{ij,1},' vs ',endo_prior_restrictions.moment{ij,2},'(',leg,')'],'interpreter','none'),
             %         if ij==maxij
             %             leg1 = num2str(endo_prior_restrictions.moment{ij,3}(:));
@@ -477,8 +477,8 @@ if ~isempty(indx_moment)
         %             stab_map_1(xmat, indx1, indx2, aname, 1, indplot, OutputDirectoryName,[],atitle);
         %         end
     end
-    for ij=1:nbr_moment_couples,
-        if length(time_matrix{ij})>1,
+    for ij=1:nbr_moment_couples
+        if length(time_matrix{ij})>1
             if ~DynareOptions.nograph
                 itmp = (find(plot_indx==ij));
                 set(0,'currentfigure',h2);
@@ -487,7 +487,7 @@ if ~isempty(indx_moment)
                 a=axis;
                 delete(htmp);
                 tmp=[];
-                for ir=1:length(itmp),
+                for ir=1:length(itmp)
                     for it=1:length(endo_prior_restrictions.moment{itmp(ir),3})
                         temp_index = find(time_matrix{ij}==endo_prior_restrictions.moment{itmp(ir),3}(it));
                         tmp(temp_index,:) = endo_prior_restrictions.moment{itmp(ir),4};
@@ -498,19 +498,19 @@ if ~isempty(indx_moment)
                 tmp(isinf(tmp(:,2)),2)=a(4);
                 hp = patch([time_matrix{ij} time_matrix{ij}(end:-1:1)],[tmp(:,1); tmp(end:-1:1,2)],'b');
                 set(hp,'FaceColor',[0.7 0.8 1])
-                hold on,
+                hold on
                 plot(time_matrix{ij},[max(moment_matrix{ij})' min(moment_matrix{ij})'],'k--','linewidth',2)
                 plot(time_matrix{ij},moment_median{ij},'k','linewidth',2)
                 plot(time_matrix{ij},[moment_distrib{ij}],'k-')
                 plot(a(1:2),[0 0],'r')
-                hold off,
+                hold off
                 axis(a)
-                box on,
+                box on
                 set(gca,'xtick',sort(time_matrix{ij}))
                 itmp = min(itmp);
                 title([endo_prior_restrictions.moment{itmp,1},' vs ',endo_prior_restrictions.moment{itmp,2}],'interpreter','none'),
             end
-            if any(iplot_indx.*plot_indx==ij),
+            if any(iplot_indx.*plot_indx==ij)
                 % MCF of the couples with logical AND
                 itmp = min(find(plot_indx==ij));
                 indx1 = find(indx_moment_matrix(:,ij)==0);
@@ -534,7 +534,7 @@ if ~isempty(indx_moment)
             end
         end
     end
-    if ~DynareOptions.nograph,
+    if ~DynareOptions.nograph
         dyn_saveas(h2,[OutputDirectoryName,filesep,fname_,'_',type,'_moment_restrictions'],DynareOptions.nodisplay,DynareOptions.graph_format);
         create_TeX_loader(DynareOptions,[OutputDirectoryName,filesep,fname_,'_',type,'_moment_restrictions'],[type ' evaluation of moment restrictions'],'moment_restrictions',type,DynareOptions.figures.textwidth*min(ij/ncol,1))
     end
diff --git a/matlab/gsa/map_ident_.m b/matlab/gsa/map_ident_.m
index 94e69f7fd..50f27cc2d 100644
--- a/matlab/gsa/map_ident_.m
+++ b/matlab/gsa/map_ident_.m
@@ -31,21 +31,21 @@ ntra   = opt_gsa.morris_ntra;
 itrans = opt_gsa.trans_ident;
 
 np = estim_params_.np;
-if opt_gsa.load_ident_files,
+if opt_gsa.load_ident_files
   gsa_flag=0;
 else
   gsa_flag=-2;
 end
 
 pnames = M_.param_names(estim_params_.param_vals(:,1),:);
-    if opt_gsa.pprior,
+    if opt_gsa.pprior
 
 filetoload=[OutputDirectoryName '/' fname_ '_prior'];
     else
 filetoload=[OutputDirectoryName '/' fname_ '_mc'];
     end
 load(filetoload,'lpmat','lpmat0','istable','T','yys','nspred','nboth','nfwrd')
-if ~isempty(lpmat0),
+if ~isempty(lpmat0)
   lpmatx=lpmat0(istable,:);
 else
   lpmatx=[];
@@ -56,24 +56,24 @@ npT = np+nshock;
 
 fname_ = M_.fname;
 
-if opt_gsa.load_ident_files==0,
+if opt_gsa.load_ident_files==0
   % th moments
 %     options_.ar = min(3,options_.ar);
 
   mss = yys(bayestopt_.mfys,:);
   mss = teff(mss(:,istable),Nsam,istable);
   yys = teff(yys(oo_.dr.order_var,istable),Nsam,istable);
-  if exist('T'),
+  if exist('T')
       [vdec, cc, ac] = mc_moments(T, lpmatx, oo_.dr);
   else
-      return,
+      return
   end
 
 
-  if opt_gsa.morris==2,
+  if opt_gsa.morris==2
    pdraws = dynare_identification(options_.options_ident,[lpmatx lpmat(istable,:)]);
 %    [pdraws, TAU, GAM] = dynare_identification(options_.options_ident,[lpmatx lpmat(istable,:)]);
-    if ~isempty(pdraws) && max(max(abs(pdraws-[lpmatx lpmat(istable,:)])))==0,
+    if ~isempty(pdraws) && max(max(abs(pdraws-[lpmatx lpmat(istable,:)])))==0
       disp(['Sample check OK ', num2str(max(max(abs(pdraws-[lpmatx lpmat(istable,:)]))))]),
       clear pdraws;
     end
@@ -86,9 +86,9 @@ if opt_gsa.load_ident_files==0,
       clear GAM gas
 %     end
   end
-  if opt_gsa.morris~=1 & M_.exo_nbr>1,
+  if opt_gsa.morris~=1 & M_.exo_nbr>1
     ifig=0;
-    for j=1:M_.exo_nbr,
+    for j=1:M_.exo_nbr
       if mod(j,6)==1
         hh=dyn_figure(options_.nodisplay,'name',['Variance decomposition shocks']);
         ifig=ifig+1;
@@ -101,13 +101,13 @@ if opt_gsa.load_ident_files==0,
       set(gca,'xticklabel',' ','fontsize',10,'xtick',[1:size(options_.varobs,1)])
       set(gca,'xlim',[0.5 size(options_.varobs,1)+0.5])
       set(gca,'ylim',[-2 102])
-      for ip=1:size(options_.varobs,1),
+      for ip=1:size(options_.varobs,1)
         text(ip,-4,deblank(options_.varobs(ip,:)),'rotation',90,'HorizontalAlignment','right','interpreter','none')
       end
       xlabel(' ')
       ylabel(' ')
       title(M_.exo_names(j,:),'interpreter','none')
-      if mod(j,6)==0 | j==M_.exo_nbr,
+      if mod(j,6)==0 | j==M_.exo_nbr
         dyn_saveas(hh,[OutputDirectoryName,'/',fname_,'_vdec_exo_',int2str(ifig)],options_.nodisplay,options_.graph_format);
         create_TeX_loader(options_,[OutputDirectoryName,'/',fname_,'_vdec_exo_',int2str(ifig)],ifig,['Variance decomposition shocks'],'vdec_exo',options_.figures.textwidth*min(iplo/3,1))
       end
@@ -135,24 +135,24 @@ if opt_gsa.load_ident_files==0,
 %     bayestopt_.restrict_aux, M_.exo_nbr);
   A = zeros(size(Aa,1),size(Aa,2)+size(Aa,1),length(istable));
   % Sig(estim_params_.var_exo(:,1))=lpmatx(1,:).^2;
-  if ~isempty(lpmatx),
+  if ~isempty(lpmatx)
       set_shocks_param(lpmatx(1,:));
   end
   A(:,:,1)=[Aa, triu(Bb*M_.Sigma_e*Bb')];
-  for j=2:length(istable),
+  for j=2:length(istable)
     dr.ghx = T(:, [1:(nc1-M_.exo_nbr)],j);
     dr.ghu = T(:, [(nc1-M_.exo_nbr+1):end], j);
     [Aa,Bb] = kalman_transition_matrix(dr, iv, ic, M_.exo_nbr);
 %       bayestopt_.restrict_var_list, ...
 %       bayestopt_.restrict_columns, ...
 %       bayestopt_.restrict_aux, M_.exo_nbr);
-    if ~isempty(lpmatx),
+    if ~isempty(lpmatx)
         set_shocks_param(lpmatx(j,:));
     end
     A(:,:,j)=[Aa, triu(Bb*M_.Sigma_e*Bb')];
   end
-  clear T;
-  clear lpmatx;
+  clear T
+  clear lpmatx
 
   [nr,nc,nn]=size(A);
   io=bayestopt_.mf2;
@@ -167,7 +167,7 @@ if opt_gsa.load_ident_files==0,
 
   [yt, j0]=teff(A,Nsam,istable);
   yt = [yys yt];
-  if opt_gsa.morris==2,
+  if opt_gsa.morris==2
 %     iii=find(std(yt(istable,:))>1.e-8);
 %     if max(max(abs(TAU-yt(istable,iii)')))<= 1.e-8,
 %       err = max(max(abs(TAU-yt(istable,iii)')));
@@ -175,7 +175,7 @@ if opt_gsa.load_ident_files==0,
       clear TAU A
 %     end
   else
-    clear A,
+    clear A
   end
   % [yt1, j01]=teff(T1,Nsam,istable);
   % [yt2, j02]=teff(T2,Nsam,istable);
@@ -184,7 +184,7 @@ if opt_gsa.load_ident_files==0,
   % yt=[yt1 yt2 ytr];
   save([OutputDirectoryName,'/',fname_,'_main_eff.mat'],'ac','cc','vdec','yt','mss')
 else
-  if opt_gsa.morris==2,
+  if opt_gsa.morris==2
 %    [pdraws, TAU, GAM] = dynare_identification([1:npT]); %,[lpmatx lpmat(istable,:)]);
 %    [pdraws, TAU, GAM] = dynare_identification(options_.options_ident);
    pdraws = dynare_identification(options_.options_ident);
@@ -205,12 +205,12 @@ end
 %   end
 %   yt = yt(:,j0);
 
-if opt_gsa.morris==1,
+if opt_gsa.morris==1
   %OutputDir = CheckPath('gsa/screen');
-  if ~isempty(vdec),
-  if opt_gsa.load_ident_files==0,
+  if ~isempty(vdec)
+  if opt_gsa.load_ident_files==0
   SAMorris = [];
-  for i=1:size(vdec,2),
+  for i=1:size(vdec,2)
     [SAmeas, SAMorris(:,:,i)] = Morris_Measure_Groups(npT, [lpmat0 lpmat], vdec(:,i),nliv);
   end
   SAvdec = squeeze(SAMorris(:,1,:))';
@@ -227,7 +227,7 @@ if opt_gsa.morris==1,
   ydum = get(gca,'ylim');
   set(gca,'ylim',[0 ydum(2)])
   set(gca,'position',[0.13 0.2 0.775 0.7])
-  for ip=1:npT,
+  for ip=1:npT
     text(ip,-2,bayestopt_.name{ip},'rotation',90,'HorizontalAlignment','right','interpreter','none')
   end
   xlabel(' ')
@@ -310,10 +310,10 @@ if opt_gsa.morris==1,
 %   end
 
 
-  if opt_gsa.load_ident_files==0,
+  if opt_gsa.load_ident_files==0
   SAMorris = [];
   ccac = [mss cc ac];
-  for i=1:size(ccac,2),
+  for i=1:size(ccac,2)
     [SAmeas, SAMorris(:,:,i)] = Morris_Measure_Groups(npT, [lpmat0 lpmat], [ccac(:,i)],nliv);
   end
   SAcc = squeeze(SAMorris(:,1,:))';
@@ -333,7 +333,7 @@ if opt_gsa.morris==1,
   ydum = get(gca,'ylim');
   set(gca,'ylim',[0 1])
   set(gca,'position',[0.13 0.2 0.775 0.7])
-  for ip=1:npT,
+  for ip=1:npT
     text(ip,-0.02,bayestopt_.name{ip},'rotation',90,'HorizontalAlignment','right','interpreter','none')
   end
   xlabel(' ')
@@ -694,9 +694,9 @@ if opt_gsa.morris==1,
 %   end
 
 
-  if opt_gsa.load_ident_files==0,
+  if opt_gsa.load_ident_files==0
   SAMorris = [];
-  for j=1:j0,
+  for j=1:j0
     [SAmeas, SAMorris(:,:,j)] = Morris_Measure_Groups(npT, [lpmat0 lpmat], yt(:,j),nliv);
   end
 
@@ -730,7 +730,7 @@ if opt_gsa.morris==1,
   set(gca,'ylim',[0 1])
   set(gca,'position',[0.13 0.2 0.775 0.7])
   xlabel(' ')
-  for ip=1:npT,
+  for ip=1:npT
 %     text(ip,-0.02,deblank(pnames(ip,:)),'rotation',90,'HorizontalAlignment','right','interpreter','none')
     text(ip,-0.02,bayestopt_.name{ip},'rotation',90,'HorizontalAlignment','right','interpreter','none')
   end
@@ -777,12 +777,12 @@ if opt_gsa.morris==1,
   %     eval(['print -depsc2 ' OutputDirectoryName '/' fname_ '_morris_redform']);
   %     eval(['print -dpdf ' OutputDirectoryName '/' fname_ '_morris_redform']);
 
-elseif opt_gsa.morris==3,
+elseif opt_gsa.morris==3
     return
     
   np=estim_params_.np;
   na=(4*np+1)*opt_gsa.Nsam;
-  for j=1:j0,
+  for j=1:j0
     [idex(j,:), yd(j,:)] = spop_ide(lpmat, yt(:,j), opt_gsa.Nsam, 5-1);
   end
   iok=find(~isnan(yt(1:opt_gsa.Nsam,1)));
@@ -793,10 +793,9 @@ elseif opt_gsa.morris==3,
     yr(iok(is),j)=[1:length(iok)]'./length(iok);
     yr(istable(length(iok)+1:end),j) = interp1(yt(iok,j),yr(iok,j),yt(istable(length(iok)+1:end),j),'','extrap');
     ineg=find(yr(:,j)<0);
-    if any(ineg),
+    if any(ineg)
       [dum, is]=sort(yr(ineg,j));
       yr(ineg(is),j)=-[length(ineg):-1:1]./length(iok);
-
     end
     [idex_r(j,:), yd_r(j,:)] = spop_ide(lpmat, yr(:,j), opt_gsa.Nsam, 5-1);
     ys_r(j,:)=yd_r(j,:)./max(yd_r(j,:));
@@ -811,10 +810,10 @@ elseif opt_gsa.morris==3,
   ee=ee([end:-1:1])./j0;
   i0=length(find(ee>0.01));
   v0=v0(:,[end:-1:1]);
-  for j=1:i0,
+  for j=1:i0
     [idex_pc(j,:), yd_pc(j,:)] = spop_ide(lpmat, yt*v0(:,j), opt_gsa.Nsam, 5-1);
   end
-  for j=1:i0,
+  for j=1:i0
     ys_pc(j,:)=yd_pc(j,:)./max(yd_pc(j,:));
   end,
   figure, bar((idex_pc.*ys_pc)./opt_gsa.Nsam), title('Relationships PCA')
@@ -825,24 +824,24 @@ elseif opt_gsa.morris==3,
   er=er([end:-1:1])./j0;
   ir0=length(find(er>0.01));
   vr=vr(:,[end:-1:1]);
-  for j=1:ir0,
+  for j=1:ir0
     [idex_pcr(j,:), yd_pcr(j,:)] = spop_ide(lpmat, yr*vr(:,j), opt_gsa.Nsam, 5-1);
   end
-  for j=1:ir0,
+  for j=1:ir0
     ys_pcr(j,:)=yd_pcr(j,:)./max(yd_pcr(j,:));
-  end,
+  end
   figure, bar((idex_pcr.*ys_pcr)./opt_gsa.Nsam), title('Relationships rank PCA')
   figure, bar((idex_pcr.*ys_pcr)'./opt_gsa.Nsam), title('Parameters rank PCA')
   
-elseif opt_gsa.morris==2,   % ISKREV staff
-  return,
+elseif opt_gsa.morris==2   % ISKREV staff
+  return
 
   
-else,  % main effects analysis
+else  % main effects analysis
   
-  if itrans==0,
+  if itrans==0
     fsuffix = '';
-  elseif itrans==1,
+  elseif itrans==1
     fsuffix = '_log';
   else
     fsuffix = '_rank';
@@ -850,7 +849,7 @@ else,  % main effects analysis
   
   imap=[1:npT];
 
-  if isempty(lpmat0),
+  if isempty(lpmat0)
       x0=lpmat(istable,:);
   else
       
@@ -989,7 +988,7 @@ else,  % main effects analysis
 %     end
 %   end
 
-  if opt_gsa.load_ident_files==0,
+  if opt_gsa.load_ident_files==0
   try 
     EET=load([OutputDirectoryName,'/SCREEN/',fname_,'_morris_IDE'],'SAcc','ir_cc','ic_cc');
   catch
@@ -1011,15 +1010,15 @@ else,  % main effects analysis
 %   siPCA = sum(siPCA,1);
 %   siPCA = siPCA./max(siPCA);
   SAcc=zeros(size(ccac,2),npT);
-  for j=1:npca, %size(ccac,2),
-    if itrans==0,
+  for j=1:npca %size(ccac,2),
+    if itrans==0
       y0 = ccac(istable,j);
-    elseif itrans==1,
+    elseif itrans==1
       y0 = log_trans_(ccac(istable,j));
     else
       y0 = trank(ccac(istable,j));
     end
-    if ~isempty(EET),
+    if ~isempty(EET)
 %       imap=find(EET.SAvdec(j,:));
 %       [dum, isort]=sort(-EET.SAvdec(j,:));
       imap=find(siPCA(j,:) >= (0.1.*max(siPCA(j,:))) );
@@ -1523,13 +1522,13 @@ else,  % main effects analysis
 
 %   figure, bar(latent'*SAcc),
   hh=dyn_figure(options_.nodisplay,'Name',['Identifiability indices in the ',fsuffix,' moments.']);
-  bar(sum(SAcc)),
+  bar(sum(SAcc))
   set(gca,'xticklabel',' ','fontsize',10,'xtick',[1:npT])
   set(gca,'xlim',[0.5 npT+0.5])
   ydum = get(gca,'ylim');
   set(gca,'ylim',[0 ydum(2)])
   set(gca,'position',[0.13 0.2 0.775 0.7])
-  for ip=1:npT,
+  for ip=1:npT
     text(ip,-0.02*(ydum(2)),bayestopt_.name{ip},'rotation',90,'HorizontalAlignment','right','interpreter','none')
     %     text(ip,-0.02,bayestopt_.name{ip},'rotation',90,'HorizontalAlignment','right','interpreter','none')
   end
diff --git a/matlab/gsa/mc_moments.m b/matlab/gsa/mc_moments.m
index b2ea93538..4fe89cee9 100644
--- a/matlab/gsa/mc_moments.m
+++ b/matlab/gsa/mc_moments.m
@@ -27,10 +27,10 @@ global options_ M_ estim_params_ oo_
   cc = zeros(nobs,nobs,nsam);
   ac = zeros(nobs,nobs*options_.ar,nsam);
   
-  for j=1:nsam,
+  for j=1:nsam
     oo_.dr.ghx = mm(:, [1:(nc1-M_.exo_nbr)],j);
     oo_.dr.ghu = mm(:, [(nc1-M_.exo_nbr+1):end], j);
-    if ~isempty(ss),
+    if ~isempty(ss)
       set_shocks_param(ss(j,:));
     end
     [vdec(:,:,j), corr, autocorr, z, zz] = th_moments(oo_.dr,options_.varobs);
diff --git a/matlab/gsa/mcf_analysis.m b/matlab/gsa/mcf_analysis.m
index e15bdea55..a8661722c 100644
--- a/matlab/gsa/mcf_analysis.m
+++ b/matlab/gsa/mcf_analysis.m
@@ -42,7 +42,7 @@ nobeha_title = options_mcf.nobeha_title;
 title = options_mcf.title;
 fname_ = options_mcf.fname_;
 xparam1=[];
-if isfield(options_mcf,'xparam1'),
+if isfield(options_mcf,'xparam1')
     xparam1=options_mcf.xparam1;
 end    
 OutputDirectoryName = options_mcf.OutputDirectoryName;
@@ -67,14 +67,14 @@ if ~isempty(indmcf)
 end
     
 
-if length(ibeha)>10 && length(inobeha)>10,
+if length(ibeha)>10 && length(inobeha)>10
     indcorr1 = stab_map_2(lpmat(ibeha,:),alpha2, pvalue_corr, beha_title);
     indcorr2 = stab_map_2(lpmat(inobeha,:),alpha2, pvalue_corr, nobeha_title);
     indcorr = union(indcorr1(:), indcorr2(:));
     indcorr = indcorr(~ismember(indcorr(:),indmcf));
     indmcf = [indmcf(:); indcorr(:)];
 end
-if ~isempty(indmcf) && ~DynareOptions.nograph,
+if ~isempty(indmcf) && ~DynareOptions.nograph
     skipline()
     xx=[];
     if ~ isempty(xparam1), xx=xparam1(indmcf); end
diff --git a/matlab/gsa/myboxplot.m b/matlab/gsa/myboxplot.m
index b71ad169e..39eba8960 100644
--- a/matlab/gsa/myboxplot.m
+++ b/matlab/gsa/myboxplot.m
@@ -35,7 +35,7 @@ if notched==1, notched=0.25; end
 a=1-notched;
 
 % ## figure out how many data sets we have
-if iscell(data), 
+if iscell(data)
   nc = length(data);
 else
 %   if isvector(data), data = data(:); end
@@ -172,7 +172,7 @@ else
 % % % % %     outliers2_y, outliers2_x, [symbol(2),"r;;"]);
 end
 
-if nargout,
+if nargout
   sout=s;
 end
 % % % endfunction
\ No newline at end of file
diff --git a/matlab/gsa/myprctilecol.m b/matlab/gsa/myprctilecol.m
index a71d21687..21c139d6b 100644
--- a/matlab/gsa/myprctilecol.m
+++ b/matlab/gsa/myprctilecol.m
@@ -1,4 +1,4 @@
-function y = myprctilecol(x,p);
+function y = myprctilecol(x,p)
 
 % Written by Marco Ratto
 % Joint Research Centre, The European Commission,
@@ -27,9 +27,9 @@ xx = sort(x);
 
 if m==1 | n==1
     m = max(m,n);
-	if m == 1,
+	if m == 1
 	   y = x*ones(length(p),1);
-	   return;
+	   return
 	end
     n = 1;
     q = 100*(0.5:m - 0.5)./m;
diff --git a/matlab/gsa/pick.m b/matlab/gsa/pick.m
index 87838acc5..8a3f53a55 100644
--- a/matlab/gsa/pick.m
+++ b/matlab/gsa/pick.m
@@ -55,7 +55,7 @@ dy=get(gca,'ylim');
 pos=get(gca,'position');
 scalex=dx(2)-dx(1);
 scaley=dy(2)-dy(1);
-if length(X)>1,
+if length(X)>1
     K = dsearchn([(Y./scaley)' (X./scalex)'],[y/scaley x/scalex]);
 else
     az=get(gca,'children');
@@ -68,7 +68,7 @@ KK=K;
 set(button1,'Label',['Save ',num2str(K)],'Callback',['scatter_callback(',num2str(KK),',''save'')']);
 set(button2,'Label',['Eval ',num2str(K)],'Callback',['scatter_callback(',num2str(KK),',''eval'')']);
 hh=findobj(gcf,'type','axes','Tag','scatter');
-for k=1:length(hh),
+for k=1:length(hh)
     axes(hh(k));
     dum=get(gca,'children');
     dumx=get(dum(end),'xdata');
@@ -76,7 +76,7 @@ for k=1:length(hh),
     xmid=min(dumx) + 0.5*(max(dumx)-min(dumx));
     hold on
     plot(dumx(KK),dumy(KK),'or');     
-    if dumx(KK) < xmid,
+    if dumx(KK) < xmid
         text(dumx(KK),dumy(KK),['  ',num2str(K)], ...
             'FontWeight','Bold',...
             'Color','r');
diff --git a/matlab/gsa/redform_map.m b/matlab/gsa/redform_map.m
index c7b257325..7d1b3787d 100644
--- a/matlab/gsa/redform_map.m
+++ b/matlab/gsa/redform_map.m
@@ -70,7 +70,7 @@ fname_ = M_.fname;
 
 bounds = prior_bounds(bayestopt_, options_.prior_trunc);
 
-if nargin==0,
+if nargin==0
     dirname='';
 end
 
@@ -100,7 +100,7 @@ if ~exist('T')
     else
         load([dirname,filesep,M_.fname,'_mc'],'T');
     end
-    if ~exist('T'),
+    if ~exist('T')
         disp('The model is too large!')
         disp('Reduced form mapping stopped!')
         return
@@ -114,7 +114,7 @@ adir0=pwd;
 
 nspred=size(T,2)-M_.exo_nbr;
 x0=lpmat(istable,:);
-if isempty(lpmat0),
+if isempty(lpmat0)
     xx0=[];
     nshocks=0;
 else
@@ -123,7 +123,7 @@ else
 end
 [kn, np]=size(x0);
 offset = length(bayestopt_.pshape)-np;
-if options_gsa_.prior_range,
+if options_gsa_.prior_range
     pshape=5*(ones(np,1));
     pd =  [NaN(np,1) NaN(np,1) bounds.lb(offset+1:end) bounds.ub(offset+1:end)];
 else
@@ -159,11 +159,11 @@ for j=1:size(anamendo,1)
         disp(['[', namendo,' vs ',namexo,']'])
 
         
-        if ~isempty(iexo),
+        if ~isempty(iexo)
             %y0=squeeze(T(iendo,iexo+nspred,istable));
             y0=squeeze(T(iendo,iexo+nspred,:));
-            if (max(y0)-min(y0))>1.e-10,
-                if mod(iplo,9)==0 && isempty(threshold) && ~options_.nograph,
+            if (max(y0)-min(y0))>1.e-10
+                if mod(iplo,9)==0 && isempty(threshold) && ~options_.nograph
                     ifig=ifig+1;
                     hfig = dyn_figure(options_.nodisplay,'name',['Reduced Form Mapping: ', namendo,' vs shocks ',int2str(ifig)]);
                     iplo=0;
@@ -171,7 +171,7 @@ for j=1:size(anamendo,1)
                 iplo=iplo+1;
                 js=js+1;
                 xdir0 = [adir,filesep,namendo,'_vs_', namexo];
-                if ilog==0 || ~isempty(threshold),
+                if ilog==0 || ~isempty(threshold)
                     if isempty(threshold)
                         if isempty(dir(xdir0))
                             mkdir(xdir0)
@@ -192,7 +192,7 @@ for j=1:size(anamendo,1)
                         if isempty(dir(xdir))
                             mkdir(xdir)
                         end
-                        if ~options_.nograph,
+                        if ~options_.nograph
                             hf=dyn_figure(options_.nodisplay,'name',['Reduced Form Mapping (Monte Carlo Filtering): ',namendo,' vs ', namexo]); 
                             hc = cumplot(y0);
                             a=axis; delete(hc);
@@ -226,7 +226,7 @@ for j=1:size(anamendo,1)
                             icheck = mcf_analysis(x0, iy, iyc, options_mcf, options_);
                             
                             lpmat=x0(iy,:);
-                            if nshocks,
+                            if nshocks
                                 lpmat0=xx0(iy,:);
                             end
                             istable=[1:length(iy)];
@@ -235,7 +235,7 @@ for j=1:size(anamendo,1)
                         else
                             icheck=[];
                         end
-                        if isempty(icheck),
+                        if isempty(icheck)
                             atitle0=['Monte Carlo Filtering for ',namendo,' vs ', namexo];
                             options_mcf.title = atitle0;
                             indmcf = redform_mcf(y0, x0, options_mcf, options_);
@@ -255,10 +255,10 @@ for j=1:size(anamendo,1)
                     silog(:,js) = redform_private(x0, y0, options_map, options_);
                 end
                 
-                if isempty(threshold) && ~options_.nograph,
+                if isempty(threshold) && ~options_.nograph
                     figure(hfig)
                     subplot(3,3,iplo),
-                    if ilog,
+                    if ilog
                         [saso, iso] = sort(-silog(:,js));
                         bar([silog(iso(1:min(np,10)),js)])
                         logflag='log';
@@ -270,7 +270,7 @@ for j=1:size(anamendo,1)
                     %set(gca,'xticklabel',pnames(iso(1:min(np,10)),:),'fontsize',8)
                     set(gca,'xticklabel',' ','fontsize',10)
                     set(gca,'xlim',[0.5 10.5])
-                    for ip=1:min(np,10),
+                    for ip=1:min(np,10)
                         text(ip,-0.02,deblank(pnames(iso(ip),:)),'rotation',90,'HorizontalAlignment','right','interpreter','none')
                     end
                     title([logflag,' ',namendo,' vs ',namexo],'interpreter','none')
@@ -283,7 +283,7 @@ for j=1:size(anamendo,1)
             end
         end
     end
-    if iplo<9 && iplo>0 && ifig && ~options_.nograph,
+    if iplo<9 && iplo>0 && ifig && ~options_.nograph
         dyn_saveas(hfig,[dirname,filesep,M_.fname,'_redform_', namendo,'_vs_shocks_',logflag,num2str(ifig)],options_.nodisplay,options_.graph_format);
         create_TeX_loader(options_,[dirname,filesep,M_.fname,'_redform_', namendo,'_vs_shocks_',logflag,num2str(ifig)],[logflag,' ',strrep(namendo,'_','\_'),' vs ',strrep(namexo,'_','\_')],['redform_', namendo,'_vs_shocks_',logflag,num2str(ifig)],options_.figures.textwidth*min(iplo/3,1))
     end
@@ -295,11 +295,11 @@ for j=1:size(anamendo,1)
         skipline()
         disp(['[', namendo,' vs lagged ',namlagendo,']'])
         
-        if ~isempty(ilagendo),
+        if ~isempty(ilagendo)
             %y0=squeeze(T(iendo,ilagendo,istable));
             y0=squeeze(T(iendo,ilagendo,:));
-            if (max(y0)-min(y0))>1.e-10,
-                if mod(iplo,9)==0 && isempty(threshold) && ~options_.nograph,
+            if (max(y0)-min(y0))>1.e-10
+                if mod(iplo,9)==0 && isempty(threshold) && ~options_.nograph
                     ifig=ifig+1;
                     hfig = dyn_figure(options_.nodisplay,'name',['Reduced Form Mapping: ' namendo,' vs lags ',int2str(ifig)]);
                     iplo=0;
@@ -307,7 +307,7 @@ for j=1:size(anamendo,1)
                 iplo=iplo+1;
                 js=js+1;
                 xdir0 = [adir,filesep,namendo,'_vs_', namlagendo];
-                if ilog==0 || ~isempty(threshold),
+                if ilog==0 || ~isempty(threshold)
                     if isempty(threshold)
                         if isempty(dir(xdir0))
                             mkdir(xdir0)
@@ -328,7 +328,7 @@ for j=1:size(anamendo,1)
                         if isempty(dir(xdir))
                             mkdir(xdir)
                         end
-                        if ~options_.nograph,
+                        if ~options_.nograph
                             hf=dyn_figure(options_.nodisplay,'name',['Reduced Form Mapping (Monte Carlo Filtering): ',namendo,' vs lagged ', namlagendo]); 
                             hc = cumplot(y0);
                             a=axis; delete(hc);
@@ -363,7 +363,7 @@ for j=1:size(anamendo,1)
                             icheck = mcf_analysis(x0, iy, iyc, options_mcf, options_);
                             
                             lpmat=x0(iy,:);
-                            if nshocks,
+                            if nshocks
                                 lpmat0=xx0(iy,:);
                             end
                             istable=[1:length(iy)];
@@ -373,7 +373,7 @@ for j=1:size(anamendo,1)
                         else
                             icheck = [];
                         end
-                        if isempty(icheck),
+                        if isempty(icheck)
                             atitle0=['Monte Carlo Filtering for ',namendo,' vs ', namlagendo];
                             options_mcf.title = atitle0;
                             indmcf = redform_mcf(y0, x0, options_mcf, options_);
@@ -395,7 +395,7 @@ for j=1:size(anamendo,1)
                 if isempty(threshold) && ~options_.nograph
                     figure(hfig),
                     subplot(3,3,iplo),
-                    if ilog,
+                    if ilog
                         [saso, iso] = sort(-silog(:,js));
                         bar([silog(iso(1:min(np,10)),js)])
                         logflag='log';
@@ -407,11 +407,11 @@ for j=1:size(anamendo,1)
                     %set(gca,'xticklabel',pnames(iso(1:min(np,10)),:),'fontsize',8)
                     set(gca,'xticklabel',' ','fontsize',10)
                     set(gca,'xlim',[0.5 10.5])
-                    for ip=1:min(np,10),
+                    for ip=1:min(np,10)
                         text(ip,-0.02,deblank(pnames(iso(ip),:)),'rotation',90,'HorizontalAlignment','right','interpreter','none')
                     end
                     title([logflag,' ',namendo,' vs ',namlagendo,'(-1)'],'interpreter','none')
-                    if iplo==9,
+                    if iplo==9
                         dyn_saveas(hfig,[dirname,filesep,M_.fname,'_redform_', namendo,'_vs_lags_',logflag,num2str(ifig)],options_.nodisplay,options_.graph_format);
                         create_TeX_loader(options_,[dirname,filesep,M_.fname,'_redform_', namendo,'_vs_lags_',logflag,num2str(ifig)],[logflag,' ',strrep(namendo,'_','\_'),' vs ',strrep(namlagendo,'_','\_'),'(-1)'],['redform_', namendo,'_vs_lags_',logflag,':',num2str(ifig)],1)
                     end
@@ -420,14 +420,14 @@ for j=1:size(anamendo,1)
             end
         end
     end
-    if iplo<9 && iplo>0 && ifig && ~options_.nograph,
+    if iplo<9 && iplo>0 && ifig && ~options_.nograph
         dyn_saveas(hfig,[dirname,filesep,M_.fname,'_redform_', namendo,'_vs_lags_',logflag,num2str(ifig)],options_.nodisplay,options_.graph_format);
         create_TeX_loader(options_,[dirname,filesep,M_.fname,'_redform_', namendo,'_vs_lags_',logflag,num2str(ifig)],[logflag,' ',strrep(namendo,'_','\_'),' vs ',strrep(namlagendo,'_','\_'),'(-1)'],['redform_', namendo,'_vs_lags_',logflag,':',num2str(ifig)],options_.figures.textwidth*min(iplo/3,1));
     end
 end
 
-if isempty(threshold) && ~options_.nograph,
-    if ilog==0,
+if isempty(threshold) && ~options_.nograph
+    if ilog==0
         hfig=dyn_figure(options_.nodisplay,'name','Reduced Form GSA'); %bar(si)
         % boxplot(si','whis',10,'symbol','r.')
         myboxplot(si',[],'.',[],10)
@@ -436,7 +436,7 @@ if isempty(threshold) && ~options_.nograph,
         set(gca,'xlim',[0.5 np+0.5])
         set(gca,'ylim',[0 1])
         set(gca,'position',[0.13 0.2 0.775 0.7])
-        for ip=1:np,
+        for ip=1:np
             text(ip,-0.02,deblank(pnames(ip,:)),'rotation',90,'HorizontalAlignment','right','interpreter','none')
         end
         title('Reduced form GSA')
@@ -452,7 +452,7 @@ if isempty(threshold) && ~options_.nograph,
         set(gca,'xlim',[0.5 np+0.5])
         set(gca,'ylim',[0 1])
         set(gca,'position',[0.13 0.2 0.775 0.7])
-        for ip=1:np,
+        for ip=1:np
             text(ip,-0.02,deblank(pnames(ip,:)),'rotation',90,'HorizontalAlignment','right','interpreter','none')
         end
         title('Reduced form GSA - Log-transformed elements')
@@ -472,20 +472,20 @@ pnames = options_map.param_names;
 pd = options_map.pd;
 pshape = options_map.pshape;
 xdir = options_map.OutputDirectoryName;
-if options_map.prior_range,
-    for j=1:np,
+if options_map.prior_range
+    for j=1:np
         x0(:,j)=(x0(:,j)-pd(j,3))./(pd(j,4)-pd(j,3));
     end
 else
     x0=priorcdf(x0,pshape, pd(:,1), pd(:,2), pd(:,3), pd(:,4));
 end
 
-if ilog,
+if ilog
     fname=[xdir filesep options_map.fname_ '_' options_map.amap_name '_log'];
 else
     fname=[xdir filesep options_map.fname_ '_' options_map.amap_name];
 end
-if iload==0,
+if iload==0
     if isempty(dir(xdir))
         mkdir(xdir)
     end
@@ -497,7 +497,7 @@ if iload==0,
 %     gsa_ = gsa_sdp(y0(1:nest), x0(1:nest,:), 2, [],[-1 -1 -1 -1 -1 0],[],0,[fname,'_est'], pnames);
     [ys,is] = sort(y0);
     istep = ceil(nrun/nest);
-    if istep>1,
+    if istep>1
     iest = is(floor(istep/2):istep:end);
     nest = length(iest);
     irest = is(setdiff([1:nrun],[floor(istep/2):istep:nrun]));
@@ -508,7 +508,7 @@ if iload==0,
         si=nan(np,1);
         return
     end
-    if ~ismember(irest(end),ifit),
+    if ~ismember(irest(end),ifit)
         ifit = union(ifit, irest(end));
     end
     nfit=length(ifit);
@@ -517,21 +517,21 @@ if iload==0,
 %     nfit=nest;
     ipred = setdiff([1:nrun],ifit);
 
-    if ilog,
+    if ilog
         [y1, tmp, isig, lam] = log_trans_(y0(iest));
         y1 = log(y0*isig+lam);
     end
-    if ~options_.nograph,
+    if ~options_.nograph
         hfig=dyn_figure(options_.nodisplay,'name',options_map.figtitle); 
         subplot(221)
-        if ilog,
-            hist(y1,30),
+        if ilog
+            hist(y1,30)
         else
-            hist(y0,30),
+            hist(y0,30)
         end
         title(options_map.title,'interpreter','none')
         subplot(222)
-        if ilog,
+        if ilog
             hc = cumplot(y1);
         else
             hc = cumplot(y0);
@@ -541,7 +541,7 @@ if iload==0,
     end
 
     gsa0 = ss_anova(y0(iest), x0(iest,:), 1);
-    if ilog,
+    if ilog
         [gsa22, gsa1, gsax] = ss_anova_log(y1(iest), x0(iest,:), isig, lam, gsa0);
     end
 %     if (gsa1.out.bic-gsa0.out.bic) < 10,
@@ -551,7 +551,7 @@ if iload==0,
 %         y0=y1;
 %         ilog=1;
 %     end
-if nfit>nest,
+if nfit>nest
     %         gsa_ = gsa_sdp(y0(1:nfit), x0(1:nfit,:), -2, gsa_.nvr*nest^3/nfit^3,[-1 -1 -1 -1 -1 0],[],0,fname, pnames);
     nvr =  gsa0.nvr*nest^3/nfit^3;
     nvr(gsa0.stat<2) = gsa0.nvr(gsa0.stat<2)*nest^5/nfit^5;
@@ -602,13 +602,13 @@ end
     save([fname,'_map.mat'],'gsa_')
     [sidum, iii]=sort(-gsa_.si);
     gsa_.x0=x00(ifit,:);
-    if ~options_.nograph,
+    if ~options_.nograph
         hmap=gsa_sdp_plot(gsa_,[fname '_map'],pnames,iii(1:min(12,np)));
         set(hmap,'name',options_map.amap_title);
     end
     gsa_.x0=x0(ifit,:);
     %   copyfile([fname,'_est.mat'],[fname,'.mat'])
-    if ~options_.nograph,
+    if ~options_.nograph
         figure(hfig);
         subplot(223),
         plot(y0(ifit),[gsa_.fit y0(ifit)],'.'),
@@ -621,8 +621,8 @@ end
 %             r2 = gsa_.r2;
 %         end
         title(['Learning sample fit - R2=' num2str(r2,2)],'interpreter','none')
-        if nfit<nrun,
-            if ilog,
+        if nfit<nrun
+            if ilog
                 yf = ss_anova_fcast(x0(ipred,:), gsa1);
                 yf = log_trans_(yf,'',isig,lam)+ss_anova_fcast(x0(ipred,:), gsax);
             else
@@ -645,7 +645,7 @@ else
     %   gsa_ = gsa_sdp_dyn(y0, x0, 0, [],[],[],0,fname, pnames);
 %     gsa_ = gsa_sdp(y0, x0, 0, [],[],[],0,fname, pnames);
     load([fname,'_map.mat'],'gsa_')
-    if ~options_.nograph,
+    if ~options_.nograph
         yf = ss_anova_fcast(x0, gsa_);
         hfig=dyn_figure(options_.nodisplay,'name',options_map.title);
         plot(y0,[yf y0],'.'),
@@ -671,7 +671,7 @@ gsa2.f0 = mean(gsa2.fit);
 gsa2.out.SSE = sum((gsa2.fit-gsa2.y).^2);
 gsa2.out.bic = gsa2.out.bic-nest*log(gsa1.out.SSE)+nest*log(gsa2.out.SSE);
 gsa2.r2 = 1-cov(gsa2.fit-gsa2.y)/cov(gsa2.y);
-for j=1:np,
+for j=1:np
     gsa2.fs(:,j) = exp(gsa1.fs(:,j)).*mean(exp(gsa1.fit-gsa1.f(:,j)))*isig-lam*isig-gsa2.f0;
     gsa2.fses(:,j) = exp(gsa1.fs(:,j)+gsa1.fses(:,j)).*mean(exp(gsa1.fit-gsa1.f(:,j)))*isig-lam*isig-gsa2.f0-gsa2.fs(:,j);
     gsa2.f(:,j) = exp(gsa1.f(:,j)).*mean(exp(gsa1.fit-gsa1.f(:,j)))*isig-lam*isig-gsa2.f0;
@@ -685,14 +685,14 @@ function [gsa22, gsa1, gsax] = ss_anova_log(y,x,isig,lam,gsa0,nvrs)
 
 [nest, np]=size(x);
 
-if nargin==6,
+if nargin==6
     gsa1 = ss_anova(y, x, 1, 0, 2, nvrs(:,1));
 else
     gsa1 = ss_anova(y, x, 1);
 end
 gsa2 = log2level_map(gsa1, isig, lam);
-if nargin >=5 && ~isempty(gsa0),
-    for j=1:np,
+if nargin >=5 && ~isempty(gsa0)
+    for j=1:np
         nvr2(j) = var(diff(gsa2.fs(:,j),2));
         nvr0(j) = var(diff(gsa0.fs(:,j),2));
     end
@@ -702,7 +702,7 @@ if nargin >=5 && ~isempty(gsa0),
     gsa1 = ss_anova(y, x, 1, 0, 2, gsa1.nvr);
     gsa2 = log2level_map(gsa1, isig, lam);
 end
-if nargin==6,
+if nargin==6
     gsax = ss_anova(gsa2.y-gsa2.fit, x, 1, 0, 2, nvrs(:,2));
 else
     gsax = ss_anova(gsa2.y-gsa2.fit, x, 1);
@@ -713,7 +713,7 @@ gsa22.f0 = mean(gsa22.fit);
 gsa22.out.SSE = sum((gsa22.fit-gsa22.y).^2);
 gsa22.out.bic = nest*log(gsa22.out.SSE/nest) + (gsax.out.df+gsa2.out.df-1)*log(nest);
 gsa22.r2 = 1-sum((gsa22.fit-gsa22.y).^2)/sum((gsa22.y-mean(gsa22.y)).^2);
-for j=1:np,
+for j=1:np
     gsa22.fs(:,j) = gsa2.fs(:,j)+gsax.fs(:,j);
     gsa22.fses(:,j) = gsax.fses(:,j);
     gsa22.f(:,j) = gsa2.f(:,j)+gsax.f(:,j);
@@ -730,7 +730,7 @@ hfig=dyn_figure(options_.nodisplay,'name',options_mcf.amcf_title);
     density] = posterior_moments(y0,1,0.9);
 post_deciles = [-inf; post_deciles; inf];
 
-for jt=1:10,
+for jt=1:10
     indy{jt}=find( (y0>post_deciles(jt)) & (y0<=post_deciles(jt+1)));
     leg{jt}=[int2str(jt) '-dec'];
 end
@@ -741,18 +741,18 @@ indmcf = indmcf(jtmp);
 nbr_par = length(indmcf);
 nrow=ceil(sqrt(nbr_par+1));
 ncol=nrow;
-if nrow*(nrow-1)>nbr_par,
+if nrow*(nrow-1)>nbr_par
     ncol=nrow-1;
 end
 
 cmap = colormap(jet(10));
-for jx=1:nbr_par,
+for jx=1:nbr_par
     subplot(nrow,ncol,jx)
     hold off
-    for jt=1:10,
+    for jt=1:10
         h=cumplot(x0(indy{jt},indmcf(jx)));
         set(h,'color', cmap(jt,:), 'linewidth', 2)
-        hold all,
+        hold all
     end
     title(options_mcf.param_names(indmcf(jx),:),'interpreter','none')
 end
diff --git a/matlab/gsa/redform_screen.m b/matlab/gsa/redform_screen.m
index 311c6b520..1a53b7e53 100644
--- a/matlab/gsa/redform_screen.m
+++ b/matlab/gsa/redform_screen.m
@@ -39,7 +39,7 @@ iload = options_gsa_.load_redform;
 nliv = options_gsa_.morris_nliv;
 
 pnames = M_.param_names(estim_params_.param_vals(:,1),:);
-if nargin==0,
+if nargin==0
   dirname='';
 end
 
@@ -53,7 +53,7 @@ nshock = length(bayestopt_.pshape)-np;
 nsok = length(find(M_.lead_lag_incidence(M_.maximum_lag,:)));
 
 js=0;
-for j=1:size(anamendo,1),
+for j=1:size(anamendo,1)
   namendo=deblank(anamendo(j,:));
   iendo=strmatch(namendo,M_.endo_names(oo_.dr.order_var,:),'exact');
 
@@ -63,10 +63,10 @@ for j=1:size(anamendo,1),
     namexo=deblank(anamexo(jx,:));
     iexo=strmatch(namexo,M_.exo_names,'exact');
 
-    if ~isempty(iexo),
+    if ~isempty(iexo)
       y0=teff(T(iendo,iexo+nspred,:),kn,istable);
-      if ~isempty(y0),
-        if mod(iplo,9)==0,
+      if ~isempty(y0)
+        if mod(iplo,9)==0
           ifig=ifig+1;
           hh=dyn_figure(options_.nodisplay,'name',[namendo,' vs. shocks ',int2str(ifig)]);
           iplo=0;
@@ -82,11 +82,11 @@ for j=1:size(anamendo,1),
         %set(gca,'xticklabel',pnames(iso(1:min(np,10)),:),'fontsize',8)
         set(gca,'xticklabel',' ','fontsize',10)
         set(gca,'xlim',[0.5 10.5])
-        for ip=1:min(np,10),
+        for ip=1:min(np,10)
           text(ip,-0.02,deblank(pnames(iso(ip),:)),'rotation',90,'HorizontalAlignment','right','interpreter','none')
         end
         title([namendo,' vs. ',namexo],'interpreter','none')
-        if iplo==9,
+        if iplo==9
           dyn_saveas(hh,[dirname,'/',M_.fname,'_', namendo,'_vs_shock_',num2str(ifig)],options_.nodisplay,options_.graph_format);
           create_TeX_loader(options_,[dirname,'/',M_.fname,'_', namendo,'_vs_shock_',num2str(ifig)],ifig,[namendo,' vs. shocks ',int2str(ifig)],[namendo,'_vs_shock'],1)
         end
@@ -94,7 +94,7 @@ for j=1:size(anamendo,1),
       end
     end
   end
-  if iplo<9 && iplo>0 && ifig,
+  if iplo<9 && iplo>0 && ifig
     dyn_saveas(hh,[dirname,'/',M_.fname,'_', namendo,'_vs_shocks_',num2str(ifig)],options_.nodisplay,options_.graph_format);
     create_TeX_loader(options_,[dirname,'/',M_.fname,'_', namendo,'_vs_shock_',num2str(ifig)],ifig,[namendo,' vs. shocks ',int2str(ifig)],[namendo,'_vs_shock'],options_.figures.textwidth*min(iplo/3))
   end
@@ -105,10 +105,10 @@ for j=1:size(anamendo,1),
     namlagendo=deblank(anamlagendo(je,:));
     ilagendo=strmatch(namlagendo,M_.endo_names(oo_.dr.order_var(M_.nstatic+1:M_.nstatic+nsok),:),'exact');
 
-    if ~isempty(ilagendo),
+    if ~isempty(ilagendo)
       y0=teff(T(iendo,ilagendo,:),kn,istable);
-      if ~isempty(y0),
-        if mod(iplo,9)==0,
+      if ~isempty(y0)
+        if mod(iplo,9)==0
           ifig=ifig+1;
           hh=dyn_figure(options_.nodisplay,'name',[namendo,' vs. lagged endogenous ',int2str(ifig)]);
           iplo=0;
@@ -124,19 +124,19 @@ for j=1:size(anamendo,1),
         %set(gca,'xticklabel',pnames(iso(1:min(np,10)),:),'fontsize',8)
         set(gca,'xticklabel',' ','fontsize',10)
         set(gca,'xlim',[0.5 10.5])
-        for ip=1:min(np,10),
+        for ip=1:min(np,10)
           text(ip,-0.02,deblank(pnames(iso(ip),:)),'rotation',90,'HorizontalAlignment','right','interpreter','none')
         end
 
         title([namendo,' vs. ',namlagendo,'(-1)'],'interpreter','none')
-        if iplo==9,
+        if iplo==9
           dyn_saveas(hh,[dirname,'/',M_.fname,'_', namendo,'_vs_lags_',num2str(ifig)],options_.nodisplay,options_.graph_format);
           create_TeX_loader(options_,[dirname,'/',M_.fname,'_', namendo,'_vs_lags_',num2str(ifig)],ifig,[namendo,' vs. lagged endogenous ',int2str(ifig)],[namendo,'_vs_lags'],1)
         end
       end
     end
   end
-  if iplo<9 && iplo>0 && ifig,
+  if iplo<9 && iplo>0 && ifig
     dyn_saveas(hh,[dirname,'/',M_.fname,'_', namendo,'_vs_lags_',num2str(ifig)],options_.nodisplay,options_.graph_format);
     create_TeX_loader(options_,[dirname,'/',M_.fname,'_', namendo,'_vs_lags_',num2str(ifig)],ifig,[namendo,' vs. lagged endogenous ',int2str(ifig)],[namendo,'_vs_lags'],options_.figures.textwidth*min(iplo/3))
   end
@@ -150,7 +150,7 @@ set(gca,'xticklabel',' ','fontsize',10,'xtick',[1:np])
 set(gca,'xlim',[0.5 np+0.5])
 set(gca,'ylim',[0 1])
 set(gca,'position',[0.13 0.2 0.775 0.7])
-for ip=1:np,
+for ip=1:np
   text(ip,-0.02,deblank(pnames(ip,:)),'rotation',90,'HorizontalAlignment','right','interpreter','none')
 end
 xlabel(' ')
diff --git a/matlab/gsa/scatter_analysis.m b/matlab/gsa/scatter_analysis.m
index ddd4fec3a..4550e5878 100644
--- a/matlab/gsa/scatter_analysis.m
+++ b/matlab/gsa/scatter_analysis.m
@@ -37,12 +37,12 @@ amcf_title = options_scatter.amcf_title;
 title = options_scatter.title;
 fname_ = options_scatter.fname_;
 xparam1=[];
-if isfield(options_scatter,'xparam1'),
+if isfield(options_scatter,'xparam1')
     xparam1=options_scatter.xparam1;
 end    
 OutputDirectoryName = options_scatter.OutputDirectoryName;
 
-if ~DynareOptions.nograph,
+if ~DynareOptions.nograph
     skipline()
     xx=[];
     if ~isempty(xparam1)
diff --git a/matlab/gsa/scatter_mcf.m b/matlab/gsa/scatter_mcf.m
index fa4229375..0f48f636b 100644
--- a/matlab/gsa/scatter_mcf.m
+++ b/matlab/gsa/scatter_mcf.m
@@ -49,7 +49,7 @@ clear Z;
 nflag = 0;
 if nargin >=3
     nflag = 1;
-end;
+end
 
 if nargin<4 || isempty(plotsymbol)
     if n*p<100, plotsymbol = 'o';
@@ -60,37 +60,37 @@ end
 if nargin<5
     fnam='';
 end
-if nargin<6,
+if nargin<6
   dirname='';
   nograph=1;
 else
   nograph=0;    
 end
-if nargin<7,
+if nargin<7
   figtitle=fnam;
 end
-if nargin<8,
+if nargin<8
   xparam1=[];
 end
-if nargin<10,
+if nargin<10
   beha_name = 'BEHAVIOUR';
   non_beha_name = 'NON-BEHAVIOUR';
 end
-if nargin==10,
+if nargin==10
   non_beha_name = ['NON-' beha_name];
 end
 
 figtitle_tex=strrep(figtitle,'_','\_');
 
 fig_nam_=[fnam];
-if ~nograph,
+if ~nograph
     hh=dyn_figure(DynareOptions.nodisplay,'name',figtitle);
 end
 
 bf = 0.1;
 ffs = 0.05/(p-1);
 ffl = (1-2*bf-0.05)/p;
-if p>1,
+if p>1
     fL = linspace(bf,1-bf+ffs,p+1);
 else
     fL = bf;
@@ -129,7 +129,7 @@ for i = 1:p
             end
             hold off;
             %             axis([-0.1 1.1 -0.1 1.1])
-            if i<p,
+            if i<p
                 set(gca,'YTickLabel',[],'YTick',[]);
             else
                 set(gca,'yaxislocation','right');
@@ -140,14 +140,14 @@ for i = 1:p
         end
         if nflag == 1
             set(gca,'fontsize',9);
-        end;
+        end
         if i==1
             if nflag == 1
                 ylabel(vnames(j,:),'Rotation',45,'interpreter','none', ...
                     'HorizontalAlignment','right','VerticalAlignment','middle');
             else
                 ylabel([num2str(j),' '],'Rotation',90)
-            end;
+            end
         end
         if j==1
             if nflag == 1
@@ -155,7 +155,7 @@ for i = 1:p
                     'HorizontalAlignment','left','VerticalAlignment','bottom')
             else
                 title(num2str(i))
-            end;
+            end
         end
         drawnow
     end
@@ -165,7 +165,7 @@ if ~isoctave
     annotation('textbox', [0.55,0,0.35,0.05],'String', non_beha_name,'Color','Red','horizontalalignment','center','interpreter','none');
 end
 
-if ~nograph,
+if ~nograph
     dyn_saveas(hh,[dirname,filesep,fig_nam_],DynareOptions.nodisplay,DynareOptions.graph_format);
     if DynareOptions.TeX && any(strcmp('eps',cellstr(DynareOptions.graph_format)))
         fidTeX = fopen([dirname,'/',fig_nam_ '.tex'],'w');
diff --git a/matlab/gsa/scatter_plots.m b/matlab/gsa/scatter_plots.m
index e64195464..852ae5b40 100644
--- a/matlab/gsa/scatter_plots.m
+++ b/matlab/gsa/scatter_plots.m
@@ -44,7 +44,7 @@ function scatter_plots(X,xp,vnames,plotsymbol, fnam, dirname, figtitle, xparam1,
 nflag = 0;
 if nargin >=3
     nflag = 1;
-end;
+end
 
 if nargin<4 || isempty(plotsymbol)
     if n*p<100, plotsymbol = 'o';
@@ -55,17 +55,17 @@ end
 if nargin<5 || isempty(fnam)
     fnam='scatter_plot';
 end
-if nargin<6 || isempty(dirname),
+if nargin<6 || isempty(dirname)
   dirname='';
   nograph=1;
   DynareOptions.nodisplay=0;
 else
   nograph=0;    
 end
-if nargin<7 || isempty(figtitle),
+if nargin<7 || isempty(figtitle)
   figtitle=fnam;
 end
-if nargin<8,
+if nargin<8
   xparam1=[];
 end
 
@@ -79,7 +79,7 @@ fig_nam_=[fnam];
 bf = 0.1;
 ffs = 0.05/(p-1);
 ffl = (1-2*bf-0.05)/p;
-if p>1,
+if p>1
     fL = linspace(bf,1-bf+ffs,p+1);
 else
     fL = bf;
@@ -135,7 +135,7 @@ for i = 1:p
             end
             hold off;
             %             axis([-0.1 1.1 -0.1 1.1])
-            if i<p,
+            if i<p
                 set(gca,'YTickLabel',[],'YTick',[]);
             else
                 set(gca,'yaxislocation','right');
@@ -146,14 +146,14 @@ for i = 1:p
         end
         if nflag == 1
             set(gca,'fontsize',9);
-        end;
+        end
         if i==1
             if nflag == 1
                 ylabel(vnames(j,:),'Rotation',45,'interpreter','none', ...
                     'HorizontalAlignment','right','VerticalAlignment','middle');
             else
                 ylabel([num2str(j),' '],'Rotation',90)
-            end;
+            end
         end
         if j==1
             if nflag == 1
@@ -161,7 +161,7 @@ for i = 1:p
                     'HorizontalAlignment','left','VerticalAlignment','bottom')
             else
                 title(num2str(i))
-            end;
+            end
         end
         drawnow
     end
@@ -171,7 +171,7 @@ end
 %     annotation('textbox', [0.55,0,0.35,0.05],'String', non_beha_name,'Color','Red','horizontalalignment','center','interpreter','none');
 % end
 
-if ~nograph,
+if ~nograph
     dyn_saveas(hh,[dirname,filesep,fig_nam_],DynareOptions.nodisplay,DynareOptions.graph_format);
     if DynareOptions.TeX && any(strcmp('eps',cellstr(DynareOptions.graph_format)))
         fidTeX = fopen([dirname,'/',fig_nam_ '.tex'],'w');
diff --git a/matlab/gsa/smirnov.m b/matlab/gsa/smirnov.m
index ed3b17397..2a96a2a7d 100644
--- a/matlab/gsa/smirnov.m
+++ b/matlab/gsa/smirnov.m
@@ -27,7 +27,7 @@ function [H,prob,d] = smirnov(x1 , x2 , alpha, iflag )
 if nargin<3
     alpha  =  0.05;
 end
-if nargin<4,
+if nargin<4
     iflag=0;
 end
 
@@ -52,7 +52,7 @@ n =  n1*n2 /(n1+n2);
 
 % Compute the d(n1,n2) statistics.
 
-if iflag==0,
+if iflag==0
     d  =  max(abs(cum1 - cum2));
 elseif iflag==-1
     d  =  max(cum2 - cum1);
diff --git a/matlab/gsa/stab_map_.m b/matlab/gsa/stab_map_.m
index 78ab1a368..20a61b844 100644
--- a/matlab/gsa/stab_map_.m
+++ b/matlab/gsa/stab_map_.m
@@ -109,7 +109,7 @@ else  % estimated parameters but no declared priors
     end
 end
 
-if nargin==0,
+if nargin==0
     OutputDirectoryName='';
 end
 
@@ -143,12 +143,12 @@ options_.periods=0;
 options_.nomoments=1;
 options_.irf=0;
 options_.noprint=1;
-if fload==0,
+if fload==0
     %   if prepSA
     %     T=zeros(size(dr_.ghx,1),size(dr_.ghx,2)+size(dr_.ghu,2),Nsam/2);
     %   end
 
-    if isfield(dr_,'ghx'),
+    if isfield(dr_,'ghx')
         egg=zeros(length(dr_.eigval),Nsam);
     end
     yys=zeros(length(dr_.ys),Nsam);
@@ -163,16 +163,16 @@ if fload==0,
 %         lpmat = prep_ide(Nsam,np,5);
 %         Nsam=size(lpmat,1);
     else
-        if np<52 && ilptau>0,
+        if np<52 && ilptau>0
             [lpmat] = qmc_sequence(np, int64(1), 0, Nsam)';
-            if np>30 || ilptau==2, % scrambled lptau
-                for j=1:np,
+            if np>30 || ilptau==2 % scrambled lptau
+                for j=1:np
                     lpmat(:,j)=lpmat(randperm(Nsam),j);
                 end
             end
         else %ilptau==0
             [lpmat] = NaN(Nsam,np);
-            for j=1:np,
+            for j=1:np
                 lpmat(:,j) = randperm(Nsam)'./(Nsam+1); %latin hypercube
             end
 
@@ -188,9 +188,9 @@ if fload==0,
     %     end
     %
     %   end
-    if pprior,
-        for j=1:nshock,
-            if opt_gsa.morris~=1,
+    if pprior
+        for j=1:nshock
+            if opt_gsa.morris~=1
                 lpmat0(:,j) = randperm(Nsam)'./(Nsam+1); %latin hypercube
             end
             if opt_gsa.prior_range
@@ -204,7 +204,7 @@ if fload==0,
             %           xdelt(:,:,j)=prior_draw_gsa(0,[lpmat0 lpmat]+deltx);
             %         end
             %       end
-            for j=1:np,
+            for j=1:np
                 lpmat(:,j)=lpmat(:,j).*(bounds.ub(j+nshock)-bounds.lb(j+nshock))+bounds.lb(j+nshock);
             end
         else
@@ -254,13 +254,13 @@ if fload==0,
         %             end
         %         end
         %load([fname_,'_mode'])
-        if neighborhood_width>0 && isempty(options_.mode_file),
+        if neighborhood_width>0 && isempty(options_.mode_file)
             xparam1 = get_all_parameters(estim_params_,M_);
         else
         eval(['load ' options_.mode_file '.mat;']);
         end
-        if neighborhood_width>0,
-            for j=1:nshock,
+        if neighborhood_width>0
+            for j=1:nshock
                 if opt_gsa.morris ~= 1
                    lpmat0(:,j) = randperm(Nsam)'./(Nsam+1); %latin hypercube
                 end
@@ -268,10 +268,10 @@ if fload==0,
                 lb=max([bounds.lb(j) xparam1(j)*(1-neighborhood_width)]);
                 lpmat0(:,j)=lpmat0(:,j).*(ub-lb)+lb;
             end
-            for j=1:np,
+            for j=1:np
                 ub=xparam1(j+nshock)*(1+sign(xparam1(j+nshock))*neighborhood_width);
                 lb=xparam1(j+nshock)*(1-sign(xparam1(j+nshock))*neighborhood_width);
-                if bounds.ub(j+nshock)>=xparam1(j) && bounds.lb(j)<=xparam1(j+nshock),
+                if bounds.ub(j+nshock)>=xparam1(j) && bounds.lb(j)<=xparam1(j+nshock)
                     ub=min([bounds.ub(j+nshock) ub]);
                     lb=max([bounds.lb(j+nshock) lb]);
                 else
@@ -283,7 +283,7 @@ if fload==0,
             d = chol(inv(hh));
             lp=randn(Nsam*2,nshock+np)*d+kron(ones(Nsam*2,1),xparam1');
             lnprior=zeros(1,Nsam*2);
-            for j=1:Nsam*2,
+            for j=1:Nsam*2
                 lnprior(j) = any(lp(j,:)'<=bounds.lb | lp(j,:)'>=bounds.ub);
             end
             ireal=[1:2*Nsam];
@@ -305,7 +305,7 @@ if fload==0,
     inorestriction=zeros(1,Nsam);
     irestriction=zeros(1,Nsam);
     infox=zeros(Nsam,1);
-    for j=1:Nsam,
+    for j=1:Nsam
         M_ = set_all_parameters([lpmat0(j,:) lpmat(j,:)]',estim_params_,M_);
         %try stoch_simul([]);
         try
@@ -315,14 +315,14 @@ if fload==0,
                 [Tt,Rr,SteadyState,info,M_,options_,oo_] = dynare_resolve(M_,options_,oo_,'restrict');
             end
             infox(j,1)=info(1);
-            if infox(j,1)==0 && ~exist('T','var'),
+            if infox(j,1)==0 && ~exist('T','var')
                 dr_=oo_.dr;
-                if prepSA,
+                if prepSA
                     try
                         T=zeros(size(dr_.ghx,1),size(dr_.ghx,2)+size(dr_.ghu,2),Nsam);
                     catch
                         ME = lasterror();
-                        if strcmp('MATLAB:nomem',ME.identifier),
+                        if strcmp('MATLAB:nomem',ME.identifier)
                             prepSA=0;
                             disp('The model is too large for storing state space matrices ...')
                             disp('for mapping reduced form or for identification')
@@ -334,26 +334,26 @@ if fload==0,
                 end
                 egg=zeros(length(dr_.eigval),Nsam);
             end
-            if infox(j,1),
+            if infox(j,1)
 %                 disp('no solution'),
-                if isfield(oo_.dr,'ghx'),
+                if isfield(oo_.dr,'ghx')
                     oo_.dr=rmfield(oo_.dr,'ghx');
                 end
-                if (infox(j,1)<3 || infox(j,1)>5) && isfield(oo_.dr,'eigval'),
+                if (infox(j,1)<3 || infox(j,1)>5) && isfield(oo_.dr,'eigval')
                     oo_.dr=rmfield(oo_.dr,'eigval');
                 end
             end
         catch ME
-            if isfield(oo_.dr,'eigval'),
+            if isfield(oo_.dr,'eigval')
                 oo_.dr=rmfield(oo_.dr,'eigval');
             end
-            if isfield(oo_.dr,'ghx'),
+            if isfield(oo_.dr,'ghx')
                 oo_.dr=rmfield(oo_.dr,'ghx');
             end
-            disp('No solution could be found'),
+            disp('No solution could be found')
         end
         dr_ = oo_.dr;
-        if isfield(dr_,'ghx'),
+        if isfield(dr_,'ghx')
             egg(:,j) = sort(dr_.eigval);
             if prepSA
                 jstab=jstab+1;
@@ -363,14 +363,14 @@ if fload==0,
                 %           bayestopt_.restrict_columns, ...
                 %           bayestopt_.restrict_aux);
             end
-            if ~exist('nspred','var'),
+            if ~exist('nspred','var')
                 nspred = dr_.nspred; %size(dr_.ghx,2);
                 nboth = dr_.nboth;
                 nfwrd = dr_.nfwrd;
             end
             info=endogenous_prior_restrictions(Tt,Rr,M_,options_,oo_);
             infox(j,1)=info(1);
-            if info(1),
+            if info(1)
                 inorestriction(j)=j;
             else
                 iunstable(j)=0;
@@ -384,13 +384,13 @@ if fload==0,
                     if any(isnan(egg(1:nspred,j)))
                         iwrong(j)=j;
                     else
-                        if (nboth || nfwrd) && abs(egg(nspred+1,j))<=options_.qz_criterium,
+                        if (nboth || nfwrd) && abs(egg(nspred+1,j))<=options_.qz_criterium
                             iindeterm(j)=j;
                         end
                     end
                 end
             else
-                if exist('egg','var'),
+                if exist('egg','var')
                     egg(:,j)=ones(size(egg,1),1).*NaN;
                 end
                 iwrong(j)=j;
@@ -402,7 +402,7 @@ if fload==0,
         dyn_waitbar(j/Nsam,h,['MC iteration ',int2str(j),'/',int2str(Nsam)])
     end
     dyn_waitbar_close(h);
-    if prepSA && jstab,
+    if prepSA && jstab
         T=T(:,:,1:jstab);
     else
         T=[];
@@ -454,7 +454,7 @@ if fload==0,
     bkpprior.p2=bayestopt_.p2;
     bkpprior.p3=bayestopt_.p3;
     bkpprior.p4=bayestopt_.p4;
-    if pprior,
+    if pprior
         if ~prepSA
             save([OutputDirectoryName filesep fname_ '_prior.mat'], ...
                 'bkpprior','lpmat','lpmat0','irestriction','iunstable','istable','iindeterm','iwrong','ixun', ...
@@ -477,19 +477,19 @@ if fload==0,
         end
     end
 else
-    if pprior,
+    if pprior
         filetoload=[OutputDirectoryName filesep fname_ '_prior.mat'];
     else
         filetoload=[OutputDirectoryName filesep fname_ '_mc.mat'];
     end
     load(filetoload,'lpmat','lpmat0','irestriction','iunstable','istable','iindeterm','iwrong','ixun','egg','yys','nspred','nboth','nfwrd','infox')
     Nsam = size(lpmat,1);
-    if pprior==0 && ~isempty(options_.mode_file),
+    if pprior==0 && ~isempty(options_.mode_file)
         eval(['load ' options_.mode_file '.mat;']);
     end
 
 
-    if prepSA && isempty(strmatch('T',who('-file', filetoload),'exact')),
+    if prepSA && isempty(strmatch('T',who('-file', filetoload),'exact'))
         h = dyn_waitbar(0,'Please wait...');
         options_.periods=0;
         options_.nomoments=1;
@@ -499,7 +499,7 @@ else
         %T=zeros(size(dr_.ghx,1),size(dr_.ghx,2)+size(dr_.ghu,2),length(istable));
         ntrans=length(istable);
         yys=NaN(length(ys_),ntrans);
-        for j=1:ntrans,
+        for j=1:ntrans
             M_.params(estim_params_.param_vals(:,1)) = lpmat(istable(j),:)';
             %stoch_simul([]);
             [Tt,Rr,SteadyState,info,M_,options_,oo_] = dynare_resolve(M_,options_,oo_,'restrict');
@@ -548,51 +548,51 @@ delete([OutputDirectoryName,filesep,fname_,'_',aindname,'.*']);
 delete([OutputDirectoryName,filesep,fname_,'_',aunstname,'.*']);
 delete([OutputDirectoryName,filesep,fname_,'_',awrongname,'.*']);
 
-if length(iunstable)>0 || length(iwrong)>0,
+if length(iunstable)>0 || length(iwrong)>0
     fprintf(['%4.1f%% of the prior support gives unique saddle-path solution.\n'],length(istable)/Nsam*100)
     fprintf(['%4.1f%% of the prior support gives explosive dynamics.\n'],(length(ixun) )/Nsam*100)
-    if ~isempty(iindeterm),
+    if ~isempty(iindeterm)
         fprintf(['%4.1f%% of the prior support gives indeterminacy.\n'],length(iindeterm)/Nsam*100)
     end
     inorestriction = istable(find(~ismember(istable,irestriction))); % violation of prior restrictions
-    if ~isempty(iwrong) || ~isempty(inorestriction),
+    if ~isempty(iwrong) || ~isempty(inorestriction)
         skipline()
-        if any(infox==49),
+        if any(infox==49)
             fprintf(['%4.1f%% of the prior support violates prior restrictions.\n'],(length(inorestriction) )/Nsam*100)
         end
-        if ~isempty(iwrong),
+        if ~isempty(iwrong)
             skipline()
             disp(['For ',num2str(length(iwrong)/Nsam*100,'%4.1f'),'% of the prior support dynare could not find a solution.'])
             skipline()
         end
-        if any(infox==1),
+        if any(infox==1)
             disp(['    For ',num2str(length(find(infox==1))/Nsam*100,'%4.1f'),'% The model doesn''t determine the current variables uniquely.'])
         end
-        if any(infox==2),
+        if any(infox==2)
             disp(['    For ',num2str(length(find(infox==2))/Nsam*100,'%4.1f'),'% MJDGGES returned an error code.'])
         end
-        if any(infox==6),
+        if any(infox==6)
             disp(['    For ',num2str(length(find(infox==6))/Nsam*100,'%4.1f'),'% The jacobian evaluated at the deterministic steady state is complex.'])
         end
-        if any(infox==19),
+        if any(infox==19)
             disp(['    For ',num2str(length(find(infox==19))/Nsam*100,'%4.1f'),'% The steadystate routine thrown an exception (inconsistent deep parameters).'])
         end
-        if any(infox==20),
+        if any(infox==20)
             disp(['    For ',num2str(length(find(infox==20))/Nsam*100,'%4.1f'),'% Cannot find the steady state.'])
         end
-        if any(infox==21),
+        if any(infox==21)
             disp(['    For ',num2str(length(find(infox==21))/Nsam*100,'%4.1f'),'% The steady state is complex.'])
         end
-        if any(infox==22),
+        if any(infox==22)
             disp(['    For ',num2str(length(find(infox==22))/Nsam*100,'%4.1f'),'% The steady has NaNs.'])
         end
-        if any(infox==23),
+        if any(infox==23)
             disp(['    For ',num2str(length(find(infox==23))/Nsam*100,'%4.1f'),'% M_.params has been updated in the steadystate routine and has complex valued scalars.'])
         end
-        if any(infox==24),
+        if any(infox==24)
             disp(['    For ',num2str(length(find(infox==24))/Nsam*100,'%4.1f'),'% M_.params has been updated in the steadystate routine and has some NaNs.'])
         end
-        if any(infox==30),
+        if any(infox==30)
             disp(['    For ',num2str(length(find(infox==30))/Nsam*100,'%4.1f'),'% Ergodic variance can''t be computed.'])
         end
 
@@ -602,7 +602,7 @@ if length(iunstable)>0 || length(iwrong)>0,
         itot = [1:Nsam];
         isolve = itot(find(~ismember(itot,iwrong))); % dynare could find a solution
         % Blanchard Kahn
-        if neighborhood_width,
+        if neighborhood_width
             options_mcf.xparam1 = xparam1(nshock+1:end);
         end
         itmp = itot(find(~ismember(itot,istable)));
@@ -613,7 +613,7 @@ if length(iunstable)>0 || length(iwrong)>0,
         options_mcf.title = 'unique solution';
         mcf_analysis(lpmat, istable, itmp, options_mcf, options_);
 
-        if ~isempty(iindeterm),
+        if ~isempty(iindeterm)
             itmp = isolve(find(~ismember(isolve,iindeterm)));
             options_mcf.amcf_name = aindname;
             options_mcf.amcf_title = aindtitle;
@@ -623,7 +623,7 @@ if length(iunstable)>0 || length(iwrong)>0,
             mcf_analysis(lpmat, itmp, iindeterm, options_mcf, options_);
         end
         
-        if ~isempty(ixun),
+        if ~isempty(ixun)
             itmp = isolve(find(~ismember(isolve,ixun)));
             options_mcf.amcf_name = aunstname;
             options_mcf.amcf_title = aunsttitle;
@@ -635,7 +635,7 @@ if length(iunstable)>0 || length(iwrong)>0,
         
         inorestriction = istable(find(~ismember(istable,irestriction))); % violation of prior restrictions
         iwrong = iwrong(find(~ismember(iwrong,inorestriction))); % what went wrong beyond prior restrictions
-        if ~isempty(iwrong),
+        if ~isempty(iwrong)
             itmp = itot(find(~ismember(itot,iwrong)));
             options_mcf.amcf_name = awrongname;
             options_mcf.amcf_title = awrongtitle;
@@ -645,8 +645,8 @@ if length(iunstable)>0 || length(iwrong)>0,
             mcf_analysis(lpmat, itmp, iwrong, options_mcf, options_);
         end
         
-        if ~isempty(irestriction),
-            if neighborhood_width,
+        if ~isempty(irestriction)
+            if neighborhood_width
                 options_mcf.xparam1 = xparam1;
             end
             np=size(bayestopt_.name,1);
@@ -699,7 +699,7 @@ xparam1=x0;
 save prior_ok.mat xparam1;
 
 options_.periods=opt.periods;
-if isfield(opt,'nomoments'),
+if isfield(opt,'nomoments')
     options_.nomoments=opt.nomoments;
 end
 options_.irf=opt.irf;
diff --git a/matlab/gsa/stab_map_1.m b/matlab/gsa/stab_map_1.m
index 8535a78ec..0bd9888e7 100644
--- a/matlab/gsa/stab_map_1.m
+++ b/matlab/gsa/stab_map_1.m
@@ -40,11 +40,11 @@ function [proba, dproba] = stab_map_1(lpmat, ibehaviour, inonbehaviour, aname, i
 
 global estim_params_ bayestopt_ M_ options_
 
-if nargin<5,
+if nargin<5
   iplot=1;
 end
 fname_ = M_.fname;
-if nargin<7,
+if nargin<7
   dirname='';
 end
 if nargin<9,
@@ -59,20 +59,20 @@ nshock = nshock + estim_params_.ncn;
 npar=size(lpmat,2);
 ishock= npar>estim_params_.np;
 
-if nargin<6,
+if nargin<6
   ipar=[];
 end
-if nargin<8 || isempty(pcrit),
+if nargin<8 || isempty(pcrit)
   pcrit=1;
 end
 
 % Smirnov test for Blanchard; 
-for j=1:npar,
+for j=1:npar
   [H,P,KSSTAT] = smirnov(lpmat(ibehaviour,j),lpmat(inonbehaviour,j));
   proba(j)=P;
   dproba(j)=KSSTAT;
 end
-if isempty(ipar),
+if isempty(ipar)
 %     ipar=find(dproba>dcrit);
     ipar=find(proba<pcrit);
 end
@@ -81,23 +81,23 @@ if iplot && ~options_.nograph
     lpmat=lpmat(:,ipar);
     ftit=bayestopt_.name(ipar+nshock*(1-ishock));
     
-    for i=1:ceil(nparplot/12),
+    for i=1:ceil(nparplot/12)
         hh=dyn_figure(options_.nodisplay,'name',atitle);
-        for j=1+12*(i-1):min(nparplot,12*i),
+        for j=1+12*(i-1):min(nparplot,12*i)
             subplot(3,4,j-12*(i-1))
-            if ~isempty(ibehaviour),
+            if ~isempty(ibehaviour)
                 h=cumplot(lpmat(ibehaviour,j));
                 set(h,'color',[0 0 1], 'linestyle',':','LineWidth',1.5)
             end
-            hold on,
-            if ~isempty(inonbehaviour),
+            hold on
+            if ~isempty(inonbehaviour)
                 h=cumplot(lpmat(inonbehaviour,j));
                 set(h,'color',[0 0 0],'LineWidth',1.5)
             end
             %     title([ftit{j},'. D-stat ', num2str(dproba(ipar(j)),2)],'interpreter','none')
             title([ftit{j},'. p-value ', num2str(proba(ipar(j)),2)],'interpreter','none')
         end
-        if nparplot>12,
+        if nparplot>12
             dyn_saveas(hh,[dirname,filesep,fname_,'_',aname,'_SA_',int2str(i)],options_.nodisplay,options_.graph_format);
             if options_.TeX && any(strcmp('eps',cellstr(options_.graph_format)))
                 fidTeX = fopen([dirname,filesep,fname_,'_',aname,'_SA_',int2str(i) '.tex'],'w');
diff --git a/matlab/gsa/stab_map_2.m b/matlab/gsa/stab_map_2.m
index beed786dc..d13435d11 100644
--- a/matlab/gsa/stab_map_2.m
+++ b/matlab/gsa/stab_map_2.m
@@ -29,17 +29,17 @@ npar=size(x,2);
 nsam=size(x,1);
 ishock= npar>estim_params_.np;
 nograph = options_.nograph;
-if nargin<4,
+if nargin<4
   fnam='';
 end
-if nargin<5,
+if nargin<5
   dirname='';
   nograph=1;
 end
-if nargin<6,
+if nargin<6
   xparam1=[];
 end
-if nargin<7,
+if nargin<7
   figtitle=fnam;
 end
 
@@ -61,7 +61,7 @@ ifig=0;
 j2=0;
 if ishock==0
   npar=estim_params_.np;
-  if ~isempty(xparam1),
+  if ~isempty(xparam1)
       xparam1=xparam1(nshock+1:end);
   end
 else
@@ -73,14 +73,14 @@ title_string_tex=['Correlation analysis for ',strrep(fnam,'_','\\_')];
 
 indcorr = [];
 entry_iter=1;
-for j=1:npar,
+for j=1:npar
     i2=find(abs(c00(:,j))>alpha2);
-    if length(i2)>0,
-        for jx=1:length(i2),
-            if pvalue(j,i2(jx))<pvalue_crit,
+    if length(i2)>0
+        for jx=1:length(i2)
+            if pvalue(j,i2(jx))<pvalue_crit
                 indcorr = [indcorr; [j i2(jx)]];
                 j2=j2+1;
-                if ishock,
+                if ishock
                     if options_.TeX
                         [param_name_temp1, param_name_tex_temp1]= get_the_name(j,options_.TeX,M_,estim_params_,options_);
                         param_name_tex_temp1 = strrep(param_name_tex_temp1,'$','');
@@ -116,8 +116,8 @@ for j=1:npar,
                 data_mat(entry_iter,1)=c0(i2(jx),j);
                 entry_iter=entry_iter+1;
                 
-                if ~nograph,
-                    if mod(j2,12)==1,
+                if ~nograph
+                    if mod(j2,12)==1
                     ifig=ifig+1;
                     hh=dyn_figure(options_.nodisplay,'name',[figtitle,' sample bivariate projection ', num2str(ifig)]);
                 end
@@ -133,7 +133,7 @@ for j=1:npar,
                 end
                 %             xlabel(deblank(estim_params_.param_names(j,:)),'interpreter','none'),
                 %             ylabel(deblank(estim_params_.param_names(i2(jx),:)),'interpreter','none'),
-                if ishock,
+                if ishock
                     xlabel(bayestopt_.name{j},'interpreter','none'),
                     ylabel(bayestopt_.name{i2(jx)},'interpreter','none'),
                 else
@@ -141,7 +141,7 @@ for j=1:npar,
                     ylabel(bayestopt_.name{i2(jx)+nshock},'interpreter','none'),
                 end
                 title(['cc = ',num2str(c0(i2(jx),j))])
-                if (mod(j2,12)==0) && j2>0,
+                if (mod(j2,12)==0) && j2>0
                     dyn_saveas(hh,[dirname,filesep,fig_nam_,int2str(ifig)],options_.nodisplay,options_.graph_format);
                     if options_.TeX && any(strcmp('eps',cellstr(options_.graph_format)))
                         fidTeX = fopen([dirname,filesep,fig_nam_,int2str(ifig),'.tex'],'w');
@@ -162,7 +162,7 @@ for j=1:npar,
             
         end
     end
-    if ~nograph && (j==(npar)) && j2>0 && (mod(j2,12)~=0),
+    if ~nograph && (j==(npar)) && j2>0 && (mod(j2,12)~=0)
         dyn_saveas(hh,[dirname,filesep,fig_nam_,int2str(ifig)],options_.nodisplay,options_.graph_format);
         if options_.TeX && any(strcmp('eps',cellstr(options_.graph_format)))
             fidTeX = fopen([dirname,filesep,fig_nam_,int2str(ifig),'.tex'],'w');
@@ -180,7 +180,7 @@ for j=1:npar,
     end    
 end
 
-if j2==0,
+if j2==0
     disp(['No correlation term with pvalue <', num2str(pvalue_crit),' and |corr. coef.| >',num2str(alpha2),' found for ',fnam])
 else
     headers=strvcat('Parameters','corrcoef');
diff --git a/matlab/gsa/stand_.m b/matlab/gsa/stand_.m
index c69ec4bf3..b6a087a53 100644
--- a/matlab/gsa/stand_.m
+++ b/matlab/gsa/stand_.m
@@ -30,11 +30,11 @@ function [y, meany, stdy] = stand_(x)
 % You should have received a copy of the GNU General Public License
 % along with Dynare.  If not, see <http://www.gnu.org/licenses/>.
 
-if nargin==0,
-    return;
+if nargin==0
+    return
 end
 
-for j=1:size(x,2);
+for j=1:size(x,2)
 meany(j)=mean(x(find(~isnan(x(:,j))),j));
 stdy(j)=std(x(find(~isnan(x(:,j))),j));
     y(:,j)=(x(:,j)-meany(j))./stdy(j);
diff --git a/matlab/gsa/tcrit.m b/matlab/gsa/tcrit.m
index 291725aad..ba5f85a9e 100644
--- a/matlab/gsa/tcrit.m
+++ b/matlab/gsa/tcrit.m
@@ -27,16 +27,16 @@ function t_crit = tcrit(n,pval0)
 % along with Dynare.  If not, see <http://www.gnu.org/licenses/>.
 
 
-if nargin==1 || isempty(pval0),
+if nargin==1 || isempty(pval0)
     pval0=0.05;
 end
-if pval0==1,
+if pval0==1
     t_crit=0;
-    return,
+    return
 end
-if pval0==0,
+if pval0==0
     t_crit=inf;
-    return,
+    return
 end
 pval = [  0.10    0.05   0.025    0.01   0.005   0.001];
 pval0=max(pval0,min(pval));
@@ -146,7 +146,7 @@ t_crit=[
 inf        1.282   1.645   1.960   2.326   2.576   3.090
 ];
 
-if n<=100,
+if n<=100
     t_crit=t_crit(n,ncol);
 else
     t_crit=t_crit(end,ncol);
diff --git a/matlab/gsa/teff.m b/matlab/gsa/teff.m
index 0956669a3..da2d04741 100644
--- a/matlab/gsa/teff.m
+++ b/matlab/gsa/teff.m
@@ -27,8 +27,8 @@ function [yt, j0, ir, ic]=teff(T,Nsam,istable)
 % along with Dynare.  If not, see <http://www.gnu.org/licenses/>.
 
 ndim = (length(size(T)));
-if ndim==3,
-if nargin==1,
+if ndim==3
+if nargin==1
   Nsam=size(T,3);
   istable = [1:Nsam]';
 end
@@ -38,7 +38,7 @@ tmin=min(T,[],3);
 j0 = length(ir);
 yt=zeros(Nsam, j0);
 
-for j=1:j0,
+for j=1:j0
   y0=squeeze(T(ir(j),ic(j),:));
   %y1=ones(size(lpmat,1),1)*NaN;
   y1=ones(Nsam,1)*NaN;
diff --git a/matlab/gsa/th_moments.m b/matlab/gsa/th_moments.m
index 5616b4045..3f7708761 100644
--- a/matlab/gsa/th_moments.m
+++ b/matlab/gsa/th_moments.m
@@ -56,13 +56,13 @@ var = gamma_y{1};
 z;
 
 %'VARIANCE DECOMPOSITION (in percent)';
-if M_.exo_nbr>1,
+if M_.exo_nbr>1
     vdec = 100*gamma_y{options_.ar+2}(i1,:);
 else
     vdec = 100*ones(size(gamma_y{1}(i1,1)));
 end
 %'MATRIX OF CORRELATIONS';
-if options_.opt_gsa.useautocorr,
+if options_.opt_gsa.useautocorr
     corr = gamma_y{1}(i1,i1)./(sd(i1)*sd(i1)');
     corr = corr-diag(diag(corr))+diag(diag(gamma_y{1}(i1,i1)));
 else
@@ -71,7 +71,7 @@ end
 if options_.ar > 0
     %'COEFFICIENTS OF AUTOCORRELATION';
     for i=1:options_.ar
-        if options_.opt_gsa.useautocorr,
+        if options_.opt_gsa.useautocorr
             autocorr{i} = gamma_y{i+1}(i1,i1);
         else
             autocorr{i} = gamma_y{i+1}(i1,i1).*(sd(i1)*sd(i1)');
diff --git a/matlab/gsa/trank.m b/matlab/gsa/trank.m
index d6ac2d2db..42eff73ce 100644
--- a/matlab/gsa/trank.m
+++ b/matlab/gsa/trank.m
@@ -1,4 +1,4 @@
-function yr = trank(y);
+function yr = trank(y)
 % yr = trank(y);
 % yr is the rank transformation of y
 %
@@ -28,7 +28,7 @@ function yr = trank(y);
 % along with Dynare.  If not, see <http://www.gnu.org/licenses/>.
 
 [nr, nc] = size(y);
-for j=1:nc,
+for j=1:nc
   [dum, is]=sort(y(:,j));
   yr(is,j)=[1:nr]'./nr;
 end
diff --git a/matlab/ident_bruteforce.m b/matlab/ident_bruteforce.m
index 41ed952d7..c42d2a7db 100644
--- a/matlab/ident_bruteforce.m
+++ b/matlab/ident_bruteforce.m
@@ -52,7 +52,7 @@ tittxt1=strrep(tittxt1, '.', '');
 
 cosnJ=zeros(k,n);
 pars{k,n}=[];
-for ll = 1:n,
+for ll = 1:n
     h = dyn_waitbar(0,['Brute force collinearity for ' int2str(ll) ' parameters.']);
     for ii = 1:k
         tmp = find([1:k]~=ii);
@@ -63,8 +63,8 @@ for ll = 1:n,
             [cosnJ2(jj,1), b(:,jj)] = cosn([J(:,ii),J(:,tmp2(jj,:))]);
         end
         cosnJ(ii,ll) = max(cosnJ2(:,1));
-        if cosnJ(ii,ll)>1.e-8,
-            if ll>1 && ((cosnJ(ii,ll)-cosnJ(ii,ll-1))<1.e-8),
+        if cosnJ(ii,ll)>1.e-8
+            if ll>1 && ((cosnJ(ii,ll)-cosnJ(ii,ll-1))<1.e-8)
                 pars{ii,ll} = [pars{ii,ll-1} NaN];
                 cosnJ(ii,ll) = cosnJ(ii,ll-1);
             else
@@ -101,10 +101,10 @@ for ll = 1:n,
         fprintf(fidTeX,'\\midrule \\endhead \n');
         fprintf(fidTeX,'\\bottomrule \\multicolumn{3}{r}{(Continued on next page)}\\endfoot \n');
         fprintf(fidTeX,'\\bottomrule\\endlastfoot \n');
-        for i=1:k,
+        for i=1:k
             plist='';
-            for ii=1:ll,
-                if ~isnan(pars{i,ll}(ii)),
+            for ii=1:ll
+                if ~isnan(pars{i,ll}(ii))
                     plist = [plist ' $' pnames_TeX(pars{i,ll}(ii),:) '\;\; $ '];
                 else
                     plist = [plist ' ---- '];
diff --git a/matlab/identification_analysis.m b/matlab/identification_analysis.m
index 88b60ca4d..e1a6e380e 100644
--- a/matlab/identification_analysis.m
+++ b/matlab/identification_analysis.m
@@ -51,7 +51,7 @@ persistent indH indJJ indLRE
 nparam=length(params);
 np=length(indx);
 offset=nparam-np;
-if ~isempty(estim_params_),
+if ~isempty(estim_params_)
     M_ = set_all_parameters(params,estim_params_,M_);
 end
 
@@ -73,7 +73,7 @@ ide_lre = struct();
 derivatives_info = struct();
 
 [A,B,ys,info,M_,options_,oo_] = dynare_resolve(M_,options_,oo_);
-if info(1)==0,
+if info(1)==0
     oo0=oo_;
     tau=[oo_.dr.ys(oo_.dr.order_var); vec(A); dyn_vech(B*M_.Sigma_e*B')];
     yy0=oo_.dr.ys(I);
@@ -86,14 +86,14 @@ if info(1)==0,
     derivatives_info.DT=dA;
     derivatives_info.DOm=dOm;
     derivatives_info.DYss=dYss;
-    if init,
+    if init
         indJJ = (find(max(abs(JJ'),[],1)>1.e-8));
         if isempty(indJJ) && any(any(isnan(JJ)))
             error('There are NaN in the JJ matrix. Please check whether your model has units roots and you forgot to set diffuse_filter=1.' )
         elseif any(any(isnan(gam)))
             error('There are NaN''s in the theoretical moments: make sure that for non-stationary models stationary transformations of non-stationary observables are used for checking identification. [TIP: use first differences].')
         end
-        while length(indJJ)<nparam && nlags<10,
+        while length(indJJ)<nparam && nlags<10
             disp('The number of moments with non-zero derivative is smaller than the number of parameters')
             disp(['Try increasing ar = ', int2str(nlags+1)])           
             nlags=nlags+1;
@@ -104,7 +104,7 @@ if info(1)==0,
             options_.ar=nlags;
             indJJ = (find(max(abs(JJ'),[],1)>1.e-8));
         end
-        if length(indJJ)<nparam,
+        if length(indJJ)<nparam
             disp('The number of moments with non-zero derivative is smaller than the number of parameters')
             disp('up to 10 lags: check your model')           
             disp('Either further increase ar or reduce the list of estimated parameters')           
@@ -121,18 +121,18 @@ if info(1)==0,
     siLRE = (gp(indLRE,:));
     ide_strength_J=NaN(1,nparam);
     ide_strength_J_prior=NaN(1,nparam);
-    if init, %~isempty(indok),
+    if init
         normaliz = NaN(1,nparam);
-        if prior_exist,
-            if ~isempty(estim_params_.var_exo),
+        if prior_exist
+            if ~isempty(estim_params_.var_exo)
                 normaliz1 = estim_params_.var_exo(:,7)'; % normalize with prior standard deviation
             else
                 normaliz1=[];
             end
-            if ~isempty(estim_params_.corrx),
+            if ~isempty(estim_params_.corrx)
                 normaliz1 = [normaliz1 estim_params_.corrx(:,8)']; % normalize with prior standard deviation
             end
-            if ~isempty(estim_params_.param_vals),
+            if ~isempty(estim_params_.param_vals)
                 normaliz1 = [normaliz1 estim_params_.param_vals(:,7)']; % normalize with prior standard deviation
             end
             %                         normaliz = max([normaliz; normaliz1]);
@@ -141,13 +141,13 @@ if info(1)==0,
         else
             normaliz1 = NaN(1,nparam);
         end
-        try,
+        try
             options_.irf = 0;
             options_.noprint = 1;
             options_.order = 1;
             options_.SpectralDensity.trigger = 0;
             options_.periods = periods+100;
-            if options_.kalman_algo > 2,
+            if options_.kalman_algo > 2
                 options_.kalman_algo = 1;
             end
             analytic_derivation = options_.analytic_derivation;
@@ -160,7 +160,7 @@ if info(1)==0,
 %                 fval = DsgeLikelihood(xparam1,data_info,options_,M_,estim_params_,bayestopt_,oo_);
             options_.analytic_derivation = analytic_derivation;
             AHess=-AHess;
-            if min(eig(AHess))<-1.e-10,
+            if min(eig(AHess))<-1.e-10
                 error('identification_analysis: Analytic Hessian is not positive semi-definite!')
             end
 %             chol(AHess);
@@ -168,7 +168,7 @@ if info(1)==0,
             deltaM = sqrt(diag(AHess));
             iflag=any((deltaM.*deltaM)==0);
             tildaM = AHess./((deltaM)*(deltaM'));
-            if iflag || rank(AHess)>rank(tildaM),
+            if iflag || rank(AHess)>rank(tildaM)
                 [ide_hess.cond, ide_hess.ind0, ide_hess.indno, ide_hess.ino, ide_hess.Mco, ide_hess.Pco] = identification_checks(AHess, 1);
             else
                 [ide_hess.cond, ide_hess.ind0, ide_hess.indno, ide_hess.ino, ide_hess.Mco, ide_hess.Pco] = identification_checks(tildaM, 1);
@@ -187,7 +187,7 @@ if info(1)==0,
             rhoM=sqrt(1./diag(inv(tildaM(indok,indok))));
 %             deltaM = deltaM.*abs(params');
             flag_score=1;
-        catch,
+        catch
 %             replic = max([replic, nparam*(nparam+1)/2*10]);
             replic = max([replic, length(indJJ)*3]);
             cmm = simulated_moment_uncertainty(indJJ, periods, replic,options_,M_,oo_);
@@ -225,7 +225,7 @@ if info(1)==0,
             deltaM = sqrt(diag(MIM));
             iflag=any((deltaM.*deltaM)==0);
             tildaM = MIM./((deltaM)*(deltaM'));
-            if iflag || rank(MIM)>rank(tildaM),
+            if iflag || rank(MIM)>rank(tildaM)
                 [ide_hess.cond, ide_hess.ind0, ide_hess.indno, ide_hess.ino, ide_hess.Mco, ide_hess.Pco] = identification_checks(MIM, 1);
             else
                 [ide_hess.cond, ide_hess.ind0, ide_hess.indno, ide_hess.ino, ide_hess.Mco, ide_hess.Pco] = identification_checks(tildaM, 1);
@@ -239,7 +239,7 @@ if info(1)==0,
 %             chh = siH(:,ind1)*((MIM(ind1,ind1))\siH(:,ind1)');
             ind1=ind1(ind1>offset);
             clre = siLRE(:,ind1-offset)*((MIM(ind1,ind1))\siLRE(:,ind1-offset)');
-            if ~isempty(indok),
+            if ~isempty(indok)
                 rhoM(indok)=sqrt(1./diag(inv(tildaM(indok,indok))));
                 normaliz(indok) = (sqrt(diag(inv(tildaM(indok,indok))))./deltaM(indok))'; %sqrt(diag(inv(MIM(indok,indok))))';
             end
@@ -253,7 +253,7 @@ if info(1)==0,
         deltaM = deltaM.*abs(params');
         deltaM(params==0)=deltaM_prior(params==0);
         quant = siJ./repmat(sqrt(diag(cmm)),1,nparam);
-        if size(quant,1)==1,
+        if size(quant,1)==1
             siJnorm = abs(quant).*normaliz1;
         else
             siJnorm = vnorm(quant).*normaliz1;
@@ -268,9 +268,9 @@ if info(1)==0,
         iy = find(diag_chh);
         indH=indH(iy);
         siH=siH(iy,:);
-        if ~isempty(iy),
+        if ~isempty(iy)
             quant = siH./repmat(sqrt(diag_chh(iy)),1,nparam);
-            if size(quant,1)==1,
+            if size(quant,1)==1
                 siHnorm = abs(quant).*normaliz1;
             else
                 siHnorm = vnorm(quant).*normaliz1;
@@ -288,9 +288,9 @@ if info(1)==0,
         iy = find(diag_clre);
         indLRE=indLRE(iy);
         siLRE=siLRE(iy,:);
-        if ~isempty(iy),
+        if ~isempty(iy)
             quant = siLRE./repmat(sqrt(diag_clre(iy)),1,np);
-            if size(quant,1)==1,
+            if size(quant,1)==1
                 siLREnorm = abs(quant).*normaliz1(offset+1:end);
             else
                 siLREnorm = vnorm(quant).*normaliz1(offset+1:end);
@@ -307,8 +307,8 @@ if info(1)==0,
         ide_model.siHnorm=siHnorm; 
         ide_lre.siLREnorm=siLREnorm; 
         ide_hess.flag_score=flag_score; 
-    end,
-    if normalize_jacobians,
+    end
+    if normalize_jacobians
         normH = max(abs(siH)')';
         normH = normH(:,ones(nparam,1));
         normJ = max(abs(siJ)')';
@@ -354,9 +354,8 @@ if info(1)==0,
         ide_moments.S = S;
         ide_moments.V = V;
     end
-    
     indok = find(max(ide_moments.indno,[],1)==0);
-    if advanced,
+    if advanced
         [ide_moments.pars, ide_moments.cosnJ] = ident_bruteforce(JJ(indJJ,:)./normJ,max_dim_cova_group,options_.TeX,name_tex,tittxt);
     end
-end    
+end
diff --git a/matlab/identification_checks.m b/matlab/identification_checks.m
index 208d7ecd4..58a2a3ea2 100644
--- a/matlab/identification_checks.m
+++ b/matlab/identification_checks.m
@@ -45,7 +45,7 @@ function [condJ, ind0, indnoJ, ixnoJ, McoJ, PcoJ, jweak, jweak_pair] = identific
 npar = size(JJ,2);
 indnoJ = zeros(1,npar);
 
-if size(JJ,1)>1,
+if size(JJ,1)>1
     ind1 = find(vnorm(JJ)>=eps); % take non-zero columns
 else
     ind1 = find(abs(JJ)>=eps); % take non-zero columns
@@ -56,12 +56,12 @@ condJ= cond(JJ1);
 rankJ = rank(JJ);
 rankJJ = rankJ;
 icheck=0;
-if npar>0 && (rankJ<npar), 
+if npar>0 && (rankJ<npar)
     % search for singular values associated to ONE individual parameter
     ee0 = [rankJJ+1:length(ind1)];
     ind11=ones(length(ind1),1);
-    for j=1:length(ee0),
-        if length(find(abs(ee1(:,ee0(j))) > 1.e-3))==1,
+    for j=1:length(ee0)
+        if length(find(abs(ee1(:,ee0(j))) > 1.e-3))==1
             icheck=1;
             ind11 = ind11.*(abs(ee1(:,ee0(j))) <= 1.e-3); % take non-zero columns
         end
@@ -69,13 +69,13 @@ if npar>0 && (rankJ<npar),
     ind1 = ind1(find(ind11)); % take non-zero columns
 end
 
-if icheck,
+if icheck
 JJ1 = JJ(:,ind1);
 [eu,ee2,ee1] = svd( JJ1, 0 );
 condJ= cond(JJ1);
 rankJ = rank(JJ);
 rankJJ = rankJ;
-end    
+end
     
 
 % if hess_flag==0,
@@ -85,10 +85,10 @@ end
 ind0 = zeros(1,npar);
 ind0(ind1) = 1;
 
-if hess_flag==0,
+if hess_flag==0
     % find near linear dependence problems:
     McoJ = NaN(npar,1);
-    for ii = 1:size(JJ1,2);
+    for ii = 1:size(JJ1,2)
         McoJ(ind1(ii),:) = cosn([JJ1(:,ii),JJ1(:,find([1:1:size(JJ1,2)]~=ii))]);
     end
 else
@@ -109,19 +109,17 @@ if npar>0 && (rankJ<npar || rankJJ<npar || min(1-McoJ)<1.e-10)
     %         - find out which parameters are involved
     %   disp('Some parameters are NOT identified by the moments included in J')
     %   disp(' ')
-    if length(ind1)<npar,
+    if length(ind1)<npar
         % parameters with zero column in JJ
         ixnoJ = ixnoJ + 1;
         indnoJ(ixnoJ,:) = (~ismember([1:npar],ind1));
     end
     ee0 = [rankJJ+1:length(ind1)];
-    for j=1:length(ee0),
+    for j=1:length(ee0)
         % linearely dependent parameters in JJ
         ixnoJ = ixnoJ + 1;
         indnoJ(ixnoJ,ind1) = (abs(ee1(:,ee0(j))) > 1.e-3)';
     end
-else  %rank(J)==length(theta) =>
-      %         disp('All parameters are identified at theta by the moments included in J')
 end
 
 % here there is no exact linear dependence, but there are several
@@ -134,19 +132,19 @@ jweak_pair=zeros(npar,npar);
 if hess_flag==0,
 PcoJ = NaN(npar,npar);
 
-for ii = 1:size(JJ1,2);
+for ii = 1:size(JJ1,2)
     PcoJ(ind1(ii),ind1(ii)) = 1;
-    for jj = ii+1:size(JJ1,2);
+    for jj = ii+1:size(JJ1,2)
         PcoJ(ind1(ii),ind1(jj)) = cosn([JJ1(:,ii),JJ1(:,jj)]);
         PcoJ(ind1(jj),ind1(ii)) = PcoJ(ind1(ii),ind1(jj));
     end
 end
 
-for j=1:npar,
-    if McoJ(j)>(1-1.e-10), 
+for j=1:npar
+    if McoJ(j)>(1-1.e-10)
         jweak(j)=1;
         [ipair, jpair] = find(PcoJ(j,j+1:end)>(1-1.e-10));
-        for jx=1:length(jpair),
+        for jx=1:length(jpair)
             jweak_pair(j, jpair(jx)+j)=1;
             jweak_pair(jpair(jx)+j, j)=1;
         end
diff --git a/matlab/initial_condition_decomposition.m b/matlab/initial_condition_decomposition.m
index 7e2f0ae2c..af92d65ac 100644
--- a/matlab/initial_condition_decomposition.m
+++ b/matlab/initial_condition_decomposition.m
@@ -93,7 +93,7 @@ gend = size(oo.SmoothedShocks.(deblank(M_.exo_names(1,:))),1); %+options_.foreca
 z = zeros(endo_nbr,endo_nbr+2,gend);
 z(:,end,:) = Smoothed_Variables_deviation_from_mean;
 
-for i=1:endo_nbr,
+for i=1:endo_nbr
     z(i,i,1) = Smoothed_Variables_deviation_from_mean(i,1);
 end
 
diff --git a/matlab/k_order_pert.m b/matlab/k_order_pert.m
index db1ef91f4..f775cb363 100644
--- a/matlab/k_order_pert.m
+++ b/matlab/k_order_pert.m
@@ -40,14 +40,14 @@ switch(order)
     [err, g_1] = k_order_perturbation(dr,M,options);
     if err
       info(1)=9;
-      return;
+      return
     end
     dr.g_1 = g_1;
   case 2
     [err, g_0, g_1, g_2] = k_order_perturbation(dr,M,options);
     if err
       info(1)=9;
-      return;
+      return
     end
     dr.g_0 = g_0;
     dr.g_1 = g_1;
@@ -58,14 +58,14 @@ switch(order)
                                                           M,options);
         if err
           info(1)=9;
-          return;
+          return
         end
     else
         [err, g_0, g_1, g_2, g_3] = k_order_perturbation(dr, ...
                                                          M,options);
         if err
           info(1)=9;
-          return;
+          return
         end
     end
     dr.g_0 = g_0;
diff --git a/matlab/kalman/likelihood/computeDLIK.m b/matlab/kalman/likelihood/computeDLIK.m
index 1acb0796f..632506ef7 100644
--- a/matlab/kalman/likelihood/computeDLIK.m
+++ b/matlab/kalman/likelihood/computeDLIK.m
@@ -24,20 +24,20 @@ persistent DK DF D2K D2F
 if notsteady
 if Zflag
     [DK,DF,DP1] = computeDKalmanZ(T,DT,DOm,P,DP,DH,Z,iF,K);
-    if nargout>4,
+    if nargout>4
         [D2K,D2F,D2P] = computeD2KalmanZ(T,DT,D2T,D2Om,P,DP,D2P,DH,Z,iF,K,DK);
     end
 else
     [DK,DF,DP1] = computeDKalman(T,DT,DOm,P,DP,DH,Z,iF,K);
-    if nargout>4,
+    if nargout>4
         [D2K,D2F,D2P] = computeD2Kalman(T,DT,D2T,D2Om,P,DP,D2P,DH,Z,iF,K,DK);
     end
 end
 DP=DP1;
-clear DP1,
+clear DP1
 else
     DP=DP;
-    if nargout>4,
+    if nargout>4
         D2P=D2P;
     end
 end
@@ -72,7 +72,7 @@ for ii = 1:k
     dKi  = DK(:,:,ii);
     dtmp(:,ii) = Da(:,ii)+dKi*v+K*Dv(:,ii);
     
-    if nargout>4,
+    if nargout>4
         diFi = -iF*DF(:,:,ii)*iF;
         for jj = 1:ii
             jcount=jcount+1;
@@ -94,7 +94,7 @@ for ii = 1:k
             D2a(:,jj,ii) = reshape(D2T(:,jcount),size(T))*tmp + DT(:,:,jj)*dtmp(:,ii) + DT(:,:,ii)*dtmp(:,jj) + T*d2tmpij;
             D2a(:,ii,jj) = D2a(:,jj,ii);
             
-            if nargout==6,
+            if nargout==6
                 Hesst(ii,jj) = getHesst_ij(v,Dv(:,ii),Dv(:,jj),d2vij,iF,diFi,diFj,d2iFij,dFj,d2Fij);
             end
         end
@@ -104,7 +104,7 @@ for ii = 1:k
     DLIK(ii,1)  = trace( iF*DF(:,:,ii) ) + 2*Dv(:,ii)'*iF*v - v'*(iF*DF(:,:,ii)*iF)*v;
 end
 
-if nargout==4,
+if nargout==4
     %         Hesst(ii,jj) = getHesst_ij(v,Dv(:,ii),Dv(:,jj),0,iF,diFi,diFj,0,dFj,0);
     vecDPmf = reshape(DF,[],k);
     D2a = 2*Dv'*iF*Dv + (vecDPmf' * kron(iF,iF) * vecDPmf);
@@ -122,7 +122,7 @@ end
 
 % end of computeDLIK
 
-function Hesst_ij = getHesst_ij(e,dei,dej,d2eij,iS,diSi,diSj,d2iSij,dSj,d2Sij);
+function Hesst_ij = getHesst_ij(e,dei,dej,d2eij,iS,diSi,diSj,d2iSij,dSj,d2Sij)
 % computes (i,j) term in the Hessian
 
 Hesst_ij = trace(diSi*dSj + iS*d2Sij) + e'*d2iSij*e + 2*(dei'*diSj*e + dei'*iS*dej + e'*diSi*dej + e'*iS*d2eij);
@@ -165,7 +165,7 @@ end
 
 % end of computeDKalmanZ
 
-function [d2K,d2S,d2P1] = computeD2Kalman(A,dA,d2A,d2Om,P0,dP0,d2P1,DH,Z,iF,K0,dK0);
+function [d2K,d2S,d2P1] = computeD2Kalman(A,dA,d2A,d2Om,P0,dP0,d2P1,DH,Z,iF,K0,dK0)
 % computes the second derivatives of the Kalman matrices
 % note: A=T in main func.
         
@@ -189,7 +189,7 @@ for ii = 1:k
 %     d2Omi = d2Om(:,:,ii);
     diFi = -iF*dFi*iF;
     dKi = dK0(:,:,ii);
-    for jj = 1:ii,
+    for jj = 1:ii
         jcount=jcount+1;
         dAj = dA(:,:,jj);
         dFj = dP0(Z,Z,jj);
@@ -233,7 +233,7 @@ end
 
 % end of computeD2Kalman
 
-function [d2K,d2S,d2P1] = computeD2KalmanZ(A,dA,d2A,d2Om,P0,dP0,d2P1,DH,Z,iF,K0,dK0);
+function [d2K,d2S,d2P1] = computeD2KalmanZ(A,dA,d2A,d2Om,P0,dP0,d2P1,DH,Z,iF,K0,dK0)
 % computes the second derivatives of the Kalman matrices
 % note: A=T in main func.
         
@@ -251,13 +251,13 @@ d2S  = zeros(no,no,k,k);
 % d2P1 = zeros(ns,ns,k,k);
 
 jcount=0;
-for ii = 1:k,
+for ii = 1:k
     dAi = dA(:,:,ii);
     dFi = Z*dP0(:,:,ii)*Z;
 %     d2Omi = d2Om(:,:,ii);
     diFi = -iF*dFi*iF;
     dKi = dK0(:,:,ii);
-    for jj = 1:ii,
+    for jj = 1:ii
         jcount=jcount+1;
         dAj = dA(:,:,jj);
         dFj = Z*dP0(:,:,jj)*Z;
diff --git a/matlab/kalman/likelihood/kalman_filter.m b/matlab/kalman/likelihood/kalman_filter.m
index 398ab1f4b..18f8307a7 100644
--- a/matlab/kalman/likelihood/kalman_filter.m
+++ b/matlab/kalman/likelihood/kalman_filter.m
@@ -123,7 +123,7 @@ notsteady   = 1;
 F_singular  = true;
 asy_hess=0;
 
-if  analytic_derivation == 0,
+if  analytic_derivation == 0
     DLIK=[];
     Hess=[];
     LIKK=[];
@@ -133,14 +133,14 @@ else
     Da    = zeros(mm,k);                            % Derivative State vector.
     dlikk = zeros(smpl,k);
     
-    if Zflag==0,
+    if Zflag==0
         C = zeros(pp,mm);
-        for ii=1:pp; C(ii,Z(ii))=1;end         % SELECTION MATRIX IN MEASUREMENT EQ. (FOR WHEN IT IS NOT CONSTANT)
+        for ii=1:pp, C(ii,Z(ii))=1; end         % SELECTION MATRIX IN MEASUREMENT EQ. (FOR WHEN IT IS NOT CONSTANT)
     else
         C=Z;
     end
     dC = zeros(pp,mm,k);   % either selection matrix or schur have zero derivatives
-    if analytic_derivation==2,
+    if analytic_derivation==2
         Hess  = zeros(k,k);                             % Initialization of the Hessian
         D2a    = zeros(mm,k,k);                             % State vector.
         d2C = zeros(pp,mm,k,k);
@@ -151,7 +151,7 @@ else
         D2T=[];
         D2Yss=[];
     end
-    if asy_hess,
+    if asy_hess
         Hess  = zeros(k,k);                             % Initialization of the Hessian
     end
     LIK={inf,DLIK,Hess};
@@ -188,7 +188,7 @@ while notsteady && t<=last
         end
     else
         F_singular = false;
-        if rescale_prediction_error_covariance,
+        if rescale_prediction_error_covariance
             log_dF = log(det(F./(sig*sig')))+2*sum(log(sig));
             iF = inv(F./(sig*sig'))./(sig*sig');
         else
@@ -204,15 +204,15 @@ while notsteady && t<=last
             Ptmp = T*(P-K*P(Z,:))*transpose(T)+QQ;
         end
         tmp = (a+K*v);
-        if analytic_derivation,
-            if analytic_derivation==2,
+        if analytic_derivation
+            if analytic_derivation==2
                 [Da,DP,DLIKt,D2a,D2P, Hesst] = computeDLIK(k,tmp,Z,Zflag,v,T,K,P,iF,Da,DYss,DT,DOm,DP,DH,notsteady,D2a,D2Yss,D2T,D2Om,D2P);
             else
                 [Da,DP,DLIKt,Hesst] = computeDLIK(k,tmp,Z,Zflag,v,T,K,P,iF,Da,DYss,DT,DOm,DP,DH,notsteady);
             end
             if t>presample
                 DLIK = DLIK + DLIKt;
-                if analytic_derivation==2 || asy_hess,
+                if analytic_derivation==2 || asy_hess
                     Hess = Hess + Hesst;
                 end
             end
@@ -232,11 +232,11 @@ end
 
 % Add observation's densities constants and divide by two.
 likk(1:s) = .5*(likk(1:s) + pp*log(2*pi));
-if analytic_derivation,
+if analytic_derivation
     DLIK = DLIK/2;
     dlikk = dlikk/2;
-    if analytic_derivation==2 || asy_hess,
-        if asy_hess==0,
+    if analytic_derivation==2 || asy_hess
+        if asy_hess==0
         Hess = Hess + tril(Hess,-1)';
         end
         Hess = -Hess/2;
@@ -245,8 +245,8 @@ end
 
 % Call steady state Kalman filter if needed.
 if t <= last
-    if analytic_derivation,
-        if analytic_derivation==2,
+    if analytic_derivation
+        if analytic_derivation==2
             [tmp, tmp2] = kalman_filter_ss(Y, t, last, a, T, K, iF, dF, Z, pp, Zflag, analytic_derivation, Da, DT, DYss, D2a, D2T, D2Yss);
         else
             [tmp, tmp2] = kalman_filter_ss(Y, t, last, a, T, K, iF, dF, Z, pp, Zflag, analytic_derivation, Da, DT, DYss, asy_hess);
@@ -263,14 +263,14 @@ if t <= last
 end
 
 % Compute minus the log-likelihood.
-if presample>diffuse_periods,
+if presample>diffuse_periods
     LIK = sum(likk(1+(presample-diffuse_periods):end));
 else
     LIK = sum(likk);
 end
 
-if analytic_derivation,
-    if analytic_derivation==2 || asy_hess,
+if analytic_derivation
+    if analytic_derivation==2 || asy_hess
         LIK={LIK, DLIK, Hess};
     else
         LIK={LIK, DLIK};
diff --git a/matlab/kalman/likelihood/kalman_filter_fast.m b/matlab/kalman/likelihood/kalman_filter_fast.m
index 4319b5502..1f6d070ae 100644
--- a/matlab/kalman/likelihood/kalman_filter_fast.m
+++ b/matlab/kalman/likelihood/kalman_filter_fast.m
@@ -194,11 +194,11 @@ end
 
 % Add observation's densities constants and divide by two.
 likk(1:s) = .5*(likk(1:s) + pp*log(2*pi));
-if analytic_derivation,
+if analytic_derivation
     DLIK = DLIK/2;
     dlikk = dlikk/2;
-    if analytic_derivation==2 || asy_hess,
-        if asy_hess==0,
+    if analytic_derivation==2 || asy_hess
+        if asy_hess==0
         Hess = Hess + tril(Hess,-1)';
         end
         Hess = -Hess/2;
@@ -207,8 +207,8 @@ end
 
 % Call steady state Kalman filter if needed.
 if t <= last
-    if analytic_derivation,
-        if analytic_derivation==2,
+    if analytic_derivation
+        if analytic_derivation==2
             [tmp, tmp2] = kalman_filter_ss(Y,t,last,a,T,K,iF,dF,Z,pp,Zflag, ...
                 analytic_derivation,Da,DT,DYss,D2a,D2T,D2Yss);
         else
@@ -218,7 +218,7 @@ if t <= last
         likk(s+1:end)=tmp2{1};
         dlikk(s+1:end,:)=tmp2{2};
         DLIK = DLIK + tmp{2};
-        if analytic_derivation==2 || asy_hess,
+        if analytic_derivation==2 || asy_hess
             Hess = Hess + tmp{3};
         end
     else
@@ -227,14 +227,14 @@ if t <= last
 end
 
 % Compute minus the log-likelihood.
-if presample>diffuse_periods,
+if presample>diffuse_periods
     LIK = sum(likk(1+(presample-diffuse_periods):end));
 else
     LIK = sum(likk);
 end
 
-if analytic_derivation,
-    if analytic_derivation==2 || asy_hess,
+if analytic_derivation
+    if analytic_derivation==2 || asy_hess
         LIK={LIK, DLIK, Hess};
     else
         LIK={LIK, DLIK};
diff --git a/matlab/kalman/likelihood/kalman_filter_ss.m b/matlab/kalman/likelihood/kalman_filter_ss.m
index 8e5f92733..b0aed34eb 100644
--- a/matlab/kalman/likelihood/kalman_filter_ss.m
+++ b/matlab/kalman/likelihood/kalman_filter_ss.m
@@ -86,18 +86,18 @@ if nargin<12
     analytic_derivation = 0;
 end
 
-if  analytic_derivation == 0,
+if  analytic_derivation == 0
     DLIK=[];
     Hess=[];
 else
     k = size(DT,3);                                 % number of structural parameters
     DLIK  = zeros(k,1);                             % Initialization of the score.
     dlikk = zeros(smpl,k);
-    if analytic_derivation==2,
+    if analytic_derivation==2
         Hess  = zeros(k,k);                             % Initialization of the Hessian
     else
         asy_hess=D2a;
-        if asy_hess,
+        if asy_hess
             Hess  = zeros(k,k);                             % Initialization of the Hessian
         else
             Hess=[];
@@ -112,14 +112,14 @@ while t <= last
         v = Y(:,t)-a(Z);
     end
     tmp = (a+K*v);
-    if analytic_derivation,
-        if analytic_derivation==2,
+    if analytic_derivation
+        if analytic_derivation==2
             [Da,junk,DLIKt,D2a,junk2, Hesst] = computeDLIK(k,tmp,Z,Zflag,v,T,K,[],iF,Da,DYss,DT,[],[],[],notsteady,D2a,D2Yss,D2T,[],[]);
         else
             [Da,junk,DLIKt,Hesst] = computeDLIK(k,tmp,Z,Zflag,v,T,K,[],iF,Da,DYss,DT,[],[],[],notsteady);
         end
         DLIK = DLIK + DLIKt;
-        if analytic_derivation==2 || asy_hess,
+        if analytic_derivation==2 || asy_hess
             Hess = Hess + Hesst;
         end
         dlikk(t-start+1,:)=DLIKt;
@@ -137,17 +137,17 @@ likk = .5*(likk + pp*log(2*pi));
 
 % Sum the observation's densities (minus the likelihood)
 LIK = sum(likk);
-if analytic_derivation,
+if analytic_derivation
     dlikk = dlikk/2;
     DLIK = DLIK/2;
     likk = {likk, dlikk};
 end
-if analytic_derivation==2 || asy_hess,
-    if asy_hess==0,
+if analytic_derivation==2 || asy_hess
+    if asy_hess==0
         Hess = Hess + tril(Hess,-1)';
     end
     Hess = -Hess/2;
     LIK={LIK,DLIK,Hess};
-elseif analytic_derivation==1,
+elseif analytic_derivation==1
     LIK={LIK,DLIK};
 end
diff --git a/matlab/kalman/likelihood/missing_observations_kalman_filter.m b/matlab/kalman/likelihood/missing_observations_kalman_filter.m
index 4d357cd29..6b584f975 100644
--- a/matlab/kalman/likelihood/missing_observations_kalman_filter.m
+++ b/matlab/kalman/likelihood/missing_observations_kalman_filter.m
@@ -123,7 +123,7 @@ while notsteady && t<=last
             end
         else
             F_singular = false;
-            if rescale_prediction_error_covariance,
+            if rescale_prediction_error_covariance
                 log_dF = log(det(F./(sig*sig')))+2*sum(log(sig));
                 iF = inv(F./(sig*sig'))./(sig*sig');
             else
diff --git a/matlab/kalman/likelihood/univariate_computeDLIK.m b/matlab/kalman/likelihood/univariate_computeDLIK.m
index 1338a84a6..defc0e290 100644
--- a/matlab/kalman/likelihood/univariate_computeDLIK.m
+++ b/matlab/kalman/likelihood/univariate_computeDLIK.m
@@ -21,12 +21,12 @@ function [Da,DP1,DLIK,D2a,D2P,Hesst] = univariate_computeDLIK(k,indx,Z,Zflag,v,K
 
 persistent DDK DDF DD2K DD2F
 
-if notsteady,
+if notsteady
     if Zflag
         Dv   = -Z*Da(:,:) - Z*DYss(:,:);
         DF = zeros(k,1);
         DK = zeros([rows(K),k]);
-        for j=1:k,
+        for j=1:k
             DF(j)=Z*DP(:,:,j)*Z'+DH;
             DK(:,j) = (DP(:,:,j)*Z')/F-PZ*DF(j)/F^2;
         end
@@ -35,9 +35,9 @@ if notsteady,
             D2v = zeros(k,k);
             D2K = zeros(rows(K),k,k);
             jcount=0;
-            for j=1:k,
+            for j=1:k
                 D2v(:,j)   = -Z*D2a(:,:,j) - Z*D2Yss(:,:,j);
-                for i=1:j,
+                for i=1:j
                     jcount=jcount+1;
                     D2F(j,i)=Z*dyn_unvech(D2P(:,jcount))*Z';
                     D2F(i,j)=D2F(j,i);
@@ -57,8 +57,8 @@ if notsteady,
             D2K = zeros(rows(K),k,k);
             D2v   = squeeze(-D2a(Z,:,:) - D2Yss(Z,:,:));
             jcount=0;
-            for j=1:k,
-                for i=1:j,
+            for j=1:k
+                for i=1:j
                     jcount=jcount+1;
                     tmp = dyn_unvech(D2P(:,jcount));
                     D2F(j,i) = tmp(Z,Z);
@@ -89,7 +89,7 @@ else
         Dv   = -Z*Da(:,:) - Z*DYss(:,:);
         if nargout>4
             D2v = zeros(k,k);
-            for j=1:k,
+            for j=1:k
                 D2v(:,j)   = -Z*D2a(:,:,j) - Z*D2Yss(:,:,j);
             end
         end
@@ -105,7 +105,7 @@ DLIK = DF/F + 2*Dv'/F*v - v^2/F^2*DF;
 if nargout==6
     Hesst = D2F/F-1/F^2*(DF*DF') + 2*D2v/F*v + 2*(Dv'*Dv)/F - 2*(DF*Dv)*v/F^2 ...
         - v^2/F^2*D2F - 2*v/F^2*(Dv'*DF') + 2*v^2/F^3*(DF*DF');
-elseif nargout==4,
+elseif nargout==4
     D2a = 1/F^2*(DF*DF') + 2*(Dv'*Dv)/F ;
 %     D2a = -1/F^2*(DF*DF') + 2*(Dv'*Dv)/F  + 2*v^2/F^3*(DF*DF') ...
 %         - 2*(DF*Dv)*v/F^2 - 2*v/F^2*(Dv'*DF');
@@ -116,9 +116,9 @@ Da = Da + DK*v+K*Dv;
 if nargout>4
     
     D2a = D2a + D2K*v;
-    for j=1:k,
+    for j=1:k
         %         D2a(:,:,j) = D2a(:,:,j) + DK*Dv(j) + DK(:,j)*Dv + K*D2v(j,:);
-        for i=1:j,
+        for i=1:j
             D2a(:,j,i) = D2a(:,j,i) + DK(:,i)*Dv(j) + DK(:,j)*Dv(i) + K*D2v(j,i);
             D2a(:,i,j) = D2a(:,j,i);
         end
@@ -127,21 +127,21 @@ if nargout>4
     
 end
 
-if notsteady,
+if notsteady
     DP1 = DP*0;
-    if Zflag,
-        for j=1:k,
+    if Zflag
+        for j=1:k
             DP1(:,:,j)=DP(:,:,j) - (DP(:,:,j)*Z')*K'-PZ*DK(:,j)';
         end
     else
-        for j=1:k,
+        for j=1:k
             DP1(:,:,j)=DP(:,:,j) - (DP(:,Z,j))*K'-PZ*DK(:,j)';
         end
     end
-    if nargout>4,
-        if Zflag,
-            for j=1:k,
-                for i=1:j,
+    if nargout>4
+        if Zflag
+            for j=1:k
+                for i=1:j
                     jcount = jcount+1;
                     tmp = dyn_unvech(D2P(:,jcount));
                     tmp = tmp - (tmp*Z')*K' - (DP(:,:,j)*Z')*DK(:,i)' ...
@@ -153,8 +153,8 @@ if notsteady,
         else
             DPZ = squeeze(DP(:,Z,:));
             jcount = 0;
-            for j=1:k,
-                for i=1:j,
+            for j=1:k
+                for i=1:j
                     jcount = jcount+1;
                     tmp = dyn_unvech(D2P(:,jcount));
                     D2PZ = tmp(:,Z);
diff --git a/matlab/kalman/likelihood/univariate_computeDstate.m b/matlab/kalman/likelihood/univariate_computeDstate.m
index a535a0a51..d4a3aaa2a 100644
--- a/matlab/kalman/likelihood/univariate_computeDstate.m
+++ b/matlab/kalman/likelihood/univariate_computeDstate.m
@@ -22,25 +22,25 @@ function [Da1,DP1,D2a,D2P] = univariate_computeDstate(k,a,P,T,Da,DP,DT,DOm,notst
 
 DP1=DP*0;
 Da1=Da*0;
-for j=1:k,
+for j=1:k
     Da1(:,j) = T*Da(:,j) + DT(:,:,j)*a;
-    if notsteady,
+    if notsteady
         DP1(:,:,j) = T*DP(:,:,j)*T'+DT(:,:,j)*P*T'+T*P*DT(:,:,j)';
     else
         DP1=DP;
     end
 end
-if notsteady,
+if notsteady
     DP1 = DP1 + DOm;
 end
-if nargout>2,
+if nargout>2
     jcount=0;
-    for j=1:k,
-        for i=1:j,
+    for j=1:k
+        for i=1:j
             jcount=jcount+1;
             D2a(:,j,i) = DT(:,:,i)*Da(:,j) + DT(:,:,j)*Da(:,i) + T*D2a(:,j,i)+ reshape(D2T(:,jcount),size(T))*a;
             D2a(:,i,j) = D2a(:,j,i);
-            if notsteady,
+            if notsteady
                 tmp = dyn_unvech(D2P(:,jcount));
                 tmp = T*tmp*T' +DT(:,:,i)*DP(:,:,j)*T'+T*DP(:,:,j)*DT(:,:,i)' + ...
                     DT(:,:,j)*DP(:,:,i)*T'+T*DP(:,:,i)*DT(:,:,j)' + ...
diff --git a/matlab/kalman/likelihood/univariate_kalman_filter.m b/matlab/kalman/likelihood/univariate_kalman_filter.m
index dd4559cd5..db1f67999 100644
--- a/matlab/kalman/likelihood/univariate_kalman_filter.m
+++ b/matlab/kalman/likelihood/univariate_kalman_filter.m
@@ -128,7 +128,7 @@ oldK = Inf;
 K = NaN(mm,pp);
 asy_hess=0;
 
-if  analytic_derivation == 0,
+if  analytic_derivation == 0
     DLIK=[];
     Hess=[];
 else
@@ -137,14 +137,14 @@ else
     Da    = zeros(mm,k);                            % Derivative State vector.
     dlik  = zeros(smpl,k);
     
-    if Zflag==0,
+    if Zflag==0
         C = zeros(pp,mm);
-        for ii=1:pp; C(ii,Z(ii))=1;end         % SELECTION MATRIX IN MEASUREMENT EQ. (FOR WHEN IT IS NOT CONSTANT)
+        for ii=1:pp, C(ii,Z(ii))=1; end         % SELECTION MATRIX IN MEASUREMENT EQ. (FOR WHEN IT IS NOT CONSTANT)
     else
         C=Z;
     end
     dC = zeros(pp,mm,k);   % either selection matrix or schur have zero derivatives
-    if analytic_derivation==2,
+    if analytic_derivation==2
         Hess  = zeros(k,k);                             % Initialization of the Hessian
         D2a    = zeros(mm,k,k);                             % State vector.
         d2C = zeros(pp,mm,k,k);
@@ -155,7 +155,7 @@ else
         D2T=[];
         D2Yss=[];
     end
-    if asy_hess,
+    if asy_hess
         Hess  = zeros(k,k);                             % Initialization of the Hessian
     end
     LIK={inf,DLIK,Hess};
@@ -186,15 +186,15 @@ while notsteady && t<=last %loop over t
                 K(:,i) = Ki;
             end
             lik(s,i) = log(Fi) + (prediction_error*prediction_error)/Fi + l2pi; %Top equation p. 175 in DK (2012)
-            if analytic_derivation,
-                if analytic_derivation==2,
+            if analytic_derivation
+                if analytic_derivation==2
                     [Da,DP,DLIKt,D2a,D2P, Hesst] = univariate_computeDLIK(k,i,z(i,:),Zflag,prediction_error,Ki,PZ,Fi,Da,DYss,DP,DH(d_index(i),:),notsteady,D2a,D2Yss,D2P);
                 else
                     [Da,DP,DLIKt,Hesst] = univariate_computeDLIK(k,i,z(i,:),Zflag,prediction_error,Ki,PZ,Fi,Da,DYss,DP,DH(d_index(i),:),notsteady);
                 end
                 if t>presample
                     DLIK = DLIK + DLIKt;
-                    if analytic_derivation==2 || asy_hess,
+                    if analytic_derivation==2 || asy_hess
                         Hess = Hess + Hesst;
                     end
                 end
@@ -207,8 +207,8 @@ while notsteady && t<=last %loop over t
             % p. 157, DK (2012)
         end
     end
-    if analytic_derivation,        
-        if analytic_derivation==2,
+    if analytic_derivation
+        if analytic_derivation==2
             [Da,DP,D2a,D2P] = univariate_computeDstate(k,a,P,T,Da,DP,DT,DOm,notsteady,D2a,D2P,D2T,D2Om);
         else
             [Da,DP] = univariate_computeDstate(k,a,P,T,Da,DP,DT,DOm,notsteady);
@@ -225,10 +225,10 @@ end
 
 % Divide by two.
 lik(1:s,:) = .5*lik(1:s,:);
-if analytic_derivation,
+if analytic_derivation
     DLIK = DLIK/2;
     dlik = dlik/2;
-    if analytic_derivation==2 || asy_hess,
+    if analytic_derivation==2 || asy_hess
 %         Hess = (Hess + Hess')/2;
         Hess = -Hess/2;
     end
@@ -236,8 +236,8 @@ end
 
 % Call steady state univariate kalman filter if needed.
 if t <= last
-    if analytic_derivation,
-        if analytic_derivation==2,
+    if analytic_derivation
+        if analytic_derivation==2
             [tmp, tmp2] = univariate_kalman_filter_ss(Y,t,last,a,P,kalman_tol,T,H,Z,pp,Zflag, ...
                 analytic_derivation,Da,DT,DYss,DP,DH,D2a,D2T,D2Yss,D2P);
         else
@@ -247,7 +247,7 @@ if t <= last
         lik(s+1:end,:)=tmp2{1};
         dlik(s+1:end,:)=tmp2{2};
         DLIK = DLIK + tmp{2};
-        if analytic_derivation==2 || asy_hess,
+        if analytic_derivation==2 || asy_hess
             Hess = Hess + tmp{3};
         end
     else
@@ -262,8 +262,8 @@ else
     LIK = sum(sum(lik));
 end
 
-if analytic_derivation,
-    if analytic_derivation==2 || asy_hess,
+if analytic_derivation
+    if analytic_derivation==2 || asy_hess
         LIK={LIK, DLIK, Hess};
     else
         LIK={LIK, DLIK};
diff --git a/matlab/kalman/likelihood/univariate_kalman_filter_ss.m b/matlab/kalman/likelihood/univariate_kalman_filter_ss.m
index cbc1d5775..fdc08cf1e 100644
--- a/matlab/kalman/likelihood/univariate_kalman_filter_ss.m
+++ b/matlab/kalman/likelihood/univariate_kalman_filter_ss.m
@@ -90,18 +90,18 @@ if nargin<12
     analytic_derivation = 0;
 end
 
-if  analytic_derivation == 0,
+if  analytic_derivation == 0
     DLIK=[];
     Hess=[];
 else
     k = size(DT,3);                                 % number of structural parameters
     DLIK  = zeros(k,1);                             % Initialization of the score.
     dlikk = zeros(smpl,k);
-    if analytic_derivation==2,
+    if analytic_derivation==2
         Hess  = zeros(k,k);                             % Initialization of the Hessian
     else
         asy_hess=D2a;
-        if asy_hess,
+        if asy_hess
             Hess  = zeros(k,k);                             % Initialization of the Hessian
         else
             Hess=[];
@@ -113,9 +113,9 @@ end
 while t<=last
     s  = t-start+1;
     PP = P;
-    if analytic_derivation,
+    if analytic_derivation
         DPP = DP;
-        if analytic_derivation==2,
+        if analytic_derivation==2
             D2PP = D2P;
         end
     end
@@ -134,14 +134,14 @@ while t<=last
             a  = a + Ki*prediction_error;
             PP = PP - PPZ*Ki';
             likk(s,i) = log(Fi) + prediction_error*prediction_error/Fi + l2pi;
-            if analytic_derivation,
-                if analytic_derivation==2,
+            if analytic_derivation
+                if analytic_derivation==2
                     [Da,DPP,DLIKt,D2a,D2PP, Hesst] = univariate_computeDLIK(k,i,Z(i,:),Zflag,prediction_error,Ki,PPZ,Fi,Da,DYss,DPP,DH(i,:),0,D2a,D2Yss,D2PP);
                 else
                     [Da,DPP,DLIKt,Hesst] = univariate_computeDLIK(k,i,Z(i,:),Zflag,prediction_error,Ki,PPZ,Fi,Da,DYss,DPP,DH(i,:),0);
                 end
                 DLIK = DLIK + DLIKt;
-                if analytic_derivation==2 || asy_hess,
+                if analytic_derivation==2 || asy_hess
                     Hess = Hess + Hesst;
                 end
                 dlikk(s,:)=dlikk(s,:)+DLIKt';
@@ -151,8 +151,8 @@ while t<=last
             % p. 157, DK (2012)
         end
     end
-    if analytic_derivation,        
-        if analytic_derivation==2,
+    if analytic_derivation
+        if analytic_derivation==2
             [Da,junk,D2a] = univariate_computeDstate(k,a,P,T,Da,DP,DT,[],0,D2a,D2P,D2T);
         else
             Da = univariate_computeDstate(k,a,P,T,Da,DP,DT,[],0);
@@ -165,15 +165,15 @@ end
 likk = .5*likk;
 
 LIK = sum(sum(likk));
-if analytic_derivation,
+if analytic_derivation
     dlikk = dlikk/2;
     DLIK = DLIK/2;
     likk = {likk, dlikk};
 end
-if analytic_derivation==2 || asy_hess,
+if analytic_derivation==2 || asy_hess
 %     Hess = (Hess + Hess')/2;
     Hess = -Hess/2;
     LIK={LIK,DLIK,Hess};
-elseif analytic_derivation==1,
+elseif analytic_derivation==1
     LIK={LIK,DLIK};
 end
\ No newline at end of file
diff --git a/matlab/lmmcp/catstruct.m b/matlab/lmmcp/catstruct.m
index 540bc99d7..014768ad9 100644
--- a/matlab/lmmcp/catstruct.m
+++ b/matlab/lmmcp/catstruct.m
@@ -87,8 +87,8 @@ function A = catstruct(varargin)
 narginchk(1, Inf);
 N = nargin ;
 
-if ~isstruct(varargin{end}),
-    if isequal(varargin{end},'sorted'),
+if ~isstruct(varargin{end})
+    if isequal(varargin{end},'sorted')
         sorted = 1 ;
         N = N-1 ;
         if N<1
@@ -112,13 +112,13 @@ FN = cell(N,1) ;
 VAL = cell(N,1) ;
 
 % parse the inputs
-for ii=1:N,
+for ii=1:N
     X = varargin{ii} ;
-    if ~isstruct(X),
+    if ~isstruct(X)
         error('catstruct:InvalidArgument',['Argument #' num2str(ii) ' is not a structure.']) ;
     end
     
-    if ~isempty(X),
+    if ~isempty(X)
         % empty structs are ignored
         if ii > 1 && ~isempty(sz0)
             if ~isequal(size(X), sz0)
@@ -137,10 +137,10 @@ end
 if NonEmptyInputsN == 0
     % all structures were empty
     A = struct([]) ;
-elseif NonEmptyInputsN == 1,
+elseif NonEmptyInputsN == 1
     % there was only one non-empty structure
     A = varargin{NonEmptyInputs} ;
-    if sorted,
+    if sorted
         A = orderfields(A) ;
     end
 else
@@ -156,12 +156,12 @@ else
       [UFN,ind] = unique(FN,'legacy') ;
     end
     
-    if numel(UFN) ~= numel(FN),
+    if numel(UFN) ~= numel(FN)
         warning('catstruct:DuplicatesFound','Fieldnames are not unique between structures.') ;
         sorted = 1 ;
     end
     
-    if sorted,
+    if sorted
         VAL = VAL(ind,:) ;
         FN = FN(ind,:) ;
     end
diff --git a/matlab/lnsrch1.m b/matlab/lnsrch1.m
index 6457793c7..56d617b35 100644
--- a/matlab/lnsrch1.m
+++ b/matlab/lnsrch1.m
@@ -103,7 +103,7 @@ while 1
     else
         if f <= fold+alf*alam*slope
             check = 0;
-            break ;
+            break
         else
             if alam == 1
                 tmplam = -slope/(2*(f-fold-slope)) ;
diff --git a/matlab/lpdfgam.m b/matlab/lpdfgam.m
index b82e43234..d54d674b4 100644
--- a/matlab/lpdfgam.m
+++ b/matlab/lpdfgam.m
@@ -1,4 +1,4 @@
-function  [ldens,Dldens,D2ldens] = lpdfgam(x,a,b);
+function  [ldens,Dldens,D2ldens] = lpdfgam(x,a,b)
 % Evaluates the logged GAMMA PDF at x.
 %
 % INPUTS     
diff --git a/matlab/lpdfgbeta.m b/matlab/lpdfgbeta.m
index e8d8af521..193a9201f 100644
--- a/matlab/lpdfgbeta.m
+++ b/matlab/lpdfgbeta.m
@@ -1,4 +1,4 @@
-function [ldens,Dldens,D2ldens] = lpdfgbeta(x,a,b,aa,bb);
+function [ldens,Dldens,D2ldens] = lpdfgbeta(x,a,b,aa,bb)
 % Evaluates the logged BETA PDF at x. 
 %
 % INPUTS 
diff --git a/matlab/lyapunov_solver.m b/matlab/lyapunov_solver.m
index a7b96c997..18f6302a2 100644
--- a/matlab/lyapunov_solver.m
+++ b/matlab/lyapunov_solver.m
@@ -63,7 +63,7 @@ elseif DynareOptions.lyapunov_srs == 1
     P = R_P' * R_P;    
 else
     P = lyapunov_symm(T,R*Q*R',DynareOptions.lyapunov_fixed_point_tol,DynareOptions.qz_criterium,DynareOptions.lyapunov_complex_threshold, [], DynareOptions.debug);
-end;
+end
 
 %@test:1
 %$ t = NaN(10,1);
diff --git a/matlab/lyapunov_symm.m b/matlab/lyapunov_symm.m
index 694415d71..f9a771825 100644
--- a/matlab/lyapunov_symm.m
+++ b/matlab/lyapunov_symm.m
@@ -54,7 +54,7 @@ if method == 3
     persistent X method1;
     if ~isempty(method1)
         method = method1;
-    end;
+    end
     if debug
         fprintf('lyapunov_symm:: [method=%d] \n',method);
     end
@@ -67,16 +67,16 @@ if method == 3
             max_it_fp = 2000;
         else
             max_it_fp = 300;
-        end;
+        end
         at = a';
         %fixed point iterations
-        while evol >  lyapunov_fixed_point_tol && it_fp < max_it_fp;
+        while evol >  lyapunov_fixed_point_tol && it_fp < max_it_fp
             X_old = X;
             X = a * X * at + b;
             evol = max(sum(abs(X - X_old))); %norm_1
             %evol = max(sum(abs(X - X_old)')); %norm_inf
             it_fp = it_fp + 1;
-        end;
+        end
         if debug
             fprintf('lyapunov_symm:: lyapunov fixed_point iterations=%d norm=%g\n',it_fp,evol);
         end
@@ -87,9 +87,9 @@ if method == 3
         else
             method1 = 3;
             x = X;
-            return;
-        end;
-    end;
+            return
+        end
+    end
 end
 
 if method
diff --git a/matlab/marginal_density.m b/matlab/marginal_density.m
index 250bb5ddf..628dd97d2 100644
--- a/matlab/marginal_density.m
+++ b/matlab/marginal_density.m
@@ -76,7 +76,7 @@ linee = 0;
 check_coverage = 1;
 increase = 1;
 while check_coverage
-    for p = 0.1:0.1:0.9;
+    for p = 0.1:0.1:0.9
         critval = chi2inv(p,npar);
         ifil = FirstLine;
         tmp = 0;
diff --git a/matlab/metropolis_hastings_initialization.m b/matlab/metropolis_hastings_initialization.m
index e18ea098a..8adfdc89e 100644
--- a/matlab/metropolis_hastings_initialization.m
+++ b/matlab/metropolis_hastings_initialization.m
@@ -223,7 +223,7 @@ if ~options_.load_mh_file && ~options_.mh_recover
     fprintf(fidlog,['    Expected number of files per block.......: ' int2str(AnticipatedNumberOfFiles) '.\n']);
     fprintf(fidlog,['    Expected number of lines in the last file: ' int2str(AnticipatedNumberOfLinesInTheLastFile) '.\n']);
     fprintf(fidlog,['\n']);
-    for j = 1:NumberOfBlocks,
+    for j = 1:NumberOfBlocks
         fprintf(fidlog,['    Initial state of the Gaussian random number generator for chain number ',int2str(j),':\n']);
         for i=1:length(record.InitialSeeds(j).Normal)
             fprintf(fidlog,['      ' num2str(record.InitialSeeds(j).Normal(i)') '\n']);
@@ -232,7 +232,7 @@ if ~options_.load_mh_file && ~options_.mh_recover
         for i=1:length(record.InitialSeeds(j).Unifor)
             fprintf(fidlog,['      ' num2str(record.InitialSeeds(j).Unifor(i)') '\n']);
         end
-    end,
+    end
     fprintf(fidlog,' \n');
     fclose(fidlog);
 elseif options_.load_mh_file && ~options_.mh_recover
diff --git a/matlab/mh_optimal_bandwidth.m b/matlab/mh_optimal_bandwidth.m
index 7355fddbd..8b5e54c7a 100644
--- a/matlab/mh_optimal_bandwidth.m
+++ b/matlab/mh_optimal_bandwidth.m
@@ -98,10 +98,10 @@ end
 %% Compute the standard deviation of the draws.
 sigma = std(data);
 %% Optimal bandwidth parameter.
-if bandwidth == 0;  % Rule of thumb bandwidth parameter (Silverman [1986].
+if bandwidth == 0  % Rule of thumb bandwidth parameter (Silverman [1986].
     h = 2*sigma*(sqrt(pi)*mu02/(12*(mu21^2)*number_of_draws))^(1/5);
     h = h*correction^(1/5);
-elseif bandwidth == -1; % Sheather and Jones [1991] plug-in estimation of the optimal bandwidth parameter. 
+elseif bandwidth == -1 % Sheather and Jones [1991] plug-in estimation of the optimal bandwidth parameter. 
     if strcmp(kernel_function,'uniform')      || ... 
             strcmp(kernel_function,'triangle')     || ... 
             strcmp(kernel_function,'epanechnikov') || ... 
@@ -123,7 +123,7 @@ elseif bandwidth == -1; % Sheather and Jones [1991] plug-in estimation of the op
     end
     Ihat2 = Ihat2/((number_of_draws^2)*g2^5);
     h     = (correction*mu02/(number_of_draws*Ihat2*mu21^2))^(1/5); % equation (22) in Skold and Roberts [2003]. 
-elseif bandwidth == -2;     % Bump killing... I compute local bandwith parameters in order to remove 
+elseif bandwidth == -2     % Bump killing... I compute local bandwith parameters in order to remove 
                             % spurious bumps introduced by long rejecting periods.   
     if strcmp(kernel_function,'uniform')      || ... 
             strcmp(kernel_function,'triangle')     || ... 
@@ -135,7 +135,7 @@ elseif bandwidth == -2;     % Bump killing... I compute local bandwith parameter
     T = zeros(n,1);
     for i=1:n
         j = i;
-        while j<= n && (data(j,1)-data(i,1))<2*eps;
+        while j<= n && (data(j,1)-data(i,1))<2*eps
             j = j+1;
         end     
         T(i) = (j-i);
@@ -151,7 +151,7 @@ elseif bandwidth == -2;     % Bump killing... I compute local bandwith parameter
     Ihat3 = -Ihat3/((n^2)*g3^7);
     g2    = abs(2*correction*k4(0)/(mu21*Ihat3*n))^(1/7);
     Ihat2 = 0;
-    for i=1:number_of_draws;
+    for i=1:number_of_draws
         Ihat2 = Ihat2 + sum(k4((data(i)-data)/g2));
     end     
     Ihat2 = Ihat2/((number_of_draws^2)*g2^5);
@@ -169,7 +169,7 @@ function correction = correction_for_repeated_draws(draws,n)
 correction = 0;
 for i=1:n
     j = i;
-    while j<=n && ( draws(j,1) - draws(i,1) )<2*eps; 
+    while j<=n && ( draws(j,1) - draws(i,1) )<2*eps
         j = j+1;
     end
     correction = correction + 2*(j-i) - 1;
diff --git a/matlab/missing/corrcoef/corrcoef.m b/matlab/missing/corrcoef/corrcoef.m
index c918c6104..e997518ac 100644
--- a/matlab/missing/corrcoef/corrcoef.m
+++ b/matlab/missing/corrcoef/corrcoef.m
@@ -138,22 +138,22 @@ elseif nargin>1
                 Y=[];
         else
                 varg = varargin;
-        end;
+        end
 
-        if length(varg)<1,
+        if length(varg)<1
                 Mode = 'Pearson';
-        elseif length(varg)==1,
+        elseif length(varg)==1
                 Mode = varg{1};
         else
-                for k = 2:2:length(varg),
+                for k = 2:2:length(varg)
                         mode = setfield(mode,lower(varg{k-1}),varg{k});
-                end;
+                end
                 if isfield(mode,'mode')
                         Mode = mode.mode;
-                end;
-        end;
-end;
-if isempty(Mode) Mode='pearson'; end;
+                end
+        end
+end
+if isempty(Mode), Mode='pearson'; end
 Mode=[Mode,'        '];
 
 
@@ -164,19 +164,19 @@ warning('off');
 [r1,c1]=size(X);
 if ~isempty(Y)
         [r2,c2]=size(Y);
-        if r1~=r2,
+        if r1~=r2
                 fprintf(2,'Error CORRCOEF: X and Y must have the same number of observations (rows).\n');
-                return;
-        end;
+                return
+        end
         NN = real(~isnan(X)')*real(~isnan(Y));
 else
         [r2,c2]=size(X);
         NN = real(~isnan(X)')*real(~isnan(X));
-end;
+end
 
 %%%%% generate combinations using indices for pairwise calculation of the correlation
 YESNAN = any(isnan(X(:))) | any(isnan(Y(:)));
-if YESNAN,
+if YESNAN
     FLAG_NANS_OCCURED=(1==1);
     if isfield(mode,'rows')
         if strcmp(mode.rows,'complete')
@@ -184,7 +184,7 @@ if YESNAN,
             X = X(ix,:);
             if ~isempty(Y)
                 Y = Y(ix,:);
-            end;
+            end
             YESNAN = 0;
             NN = size(X,1);
         elseif strcmp(mode.rows,'all')
@@ -192,10 +192,10 @@ if YESNAN,
             %%NN(NN < size(X,1)) = NaN;
         elseif strcmp(mode.rows,'pairwise')
             %%% default
-        end;
-    end;
-end;
-if isempty(Y),
+        end
+    end
+end
+if isempty(Y)
         IX = ones(c1)-diag(ones(c1,1));
         [jx, jy ] = find(IX);
         [jxo,jyo] = find(IX);
@@ -208,13 +208,13 @@ else
         IX = ones(c1,c2);
         [jxo,jyo] = find(IX);
     R = zeros(c1,c2);
-end;
+end
 
-if strcmp(lower(Mode(1:7)),'pearson');
+if strcmp(lower(Mode(1:7)),'pearson')
         % see http://mathworld.wolfram.com/CorrelationCoefficient.html
-    if ~YESNAN,
+    if ~YESNAN
                 [S,N,SSQ] = sumskipnan(X,1);
-                if ~isempty(Y),
+                if ~isempty(Y)
                     [S2,N2,SSQ2] = sumskipnan(Y,1);
                         CC = X'*Y;
                         M1 = S./N;
@@ -227,12 +227,12 @@ if strcmp(lower(Mode(1:7)),'pearson');
                         cc = CC./NN - M'*M;
                         v  = SSQ./N - M.*M; %max(N-1,0);
                         R  = cc./sqrt(v'*v);
-                end;
+                end
         else
-                if ~isempty(Y),
+                if ~isempty(Y)
                         X  = [X,Y];
-                end;
-                for k = 1:length(jx),
+                end
+                for k = 1:length(jx)
                         %ik = ~any(isnan(X(:,[jx(k),jy(k)])),2);
                         ik = ~isnan(X(:,jx(k))) & ~isnan(X(:,jy(k)));
                         [s,n,s2] = sumskipnan(X(ik,[jx(k),jy(k)]),1);
@@ -241,83 +241,83 @@ if strcmp(lower(Mode(1:7)),'pearson');
                         cc = cc/n(1) - prod(s./n);
                         %r(k) = cc./sqrt(prod(v));
                         R(jxo(k),jyo(k)) = cc./sqrt(prod(v));
-                end;
+                end
     end
 
-elseif strcmp(lower(Mode(1:4)),'rank');
+elseif strcmp(lower(Mode(1:4)),'rank')
         % see [ 6] http://mathworld.wolfram.com/SpearmanRankCorrelationCoefficient.html
-    if ~YESNAN,
+    if ~YESNAN
                 if isempty(Y)
                     R = corrcoef(ranks(X));
                 else
                         R = corrcoef(ranks(X),ranks(Y));
-                end;
+                end
         else
-                if ~isempty(Y),
+                if ~isempty(Y)
                         X = [X,Y];
-                end;
-                for k = 1:length(jx),
+                end
+                for k = 1:length(jx)
                         %ik = ~any(isnan(X(:,[jx(k),jy(k)])),2);
                         ik = ~isnan(X(:,jx(k))) & ~isnan(X(:,jy(k)));
                         il = ranks(X(ik,[jx(k),jy(k)]));
                         R(jxo(k),jyo(k)) = corrcoef(il(:,1),il(:,2));
-                end;
+                end
         X = ranks(X);
-    end;
+    end
 
-elseif strcmp(lower(Mode(1:8)),'spearman');
+elseif strcmp(lower(Mode(1:8)),'spearman')
         % see [ 6] http://mathworld.wolfram.com/SpearmanRankCorrelationCoefficient.html
-        if ~isempty(Y),
+        if ~isempty(Y)
                 X = [X,Y];
-        end;
+        end
 
         n = repmat(nan,c1,c2);
 
-        if ~YESNAN,
+        if ~YESNAN
                 iy = ranks(X);	%  calculates ranks;
 
-                for k = 1:length(jx),
+                for k = 1:length(jx)
                         [R(jxo(k),jyo(k)),n(jxo(k),jyo(k))] = sumskipnan((iy(:,jx(k)) - iy(:,jy(k))).^2);	% NN is the number of non-missing values
-                end;
+                end
         else
-                for k = 1:length(jx),
+                for k = 1:length(jx)
                         %ik = ~any(isnan(X(:,[jx(k),jy(k)])),2);
                         ik = ~isnan(X(:,jx(k))) & ~isnan(X(:,jy(k)));
                         il = ranks(X(ik,[jx(k),jy(k)]));
                         % NN is the number of non-missing values
                         [R(jxo(k),jyo(k)),n(jxo(k),jyo(k))] = sumskipnan((il(:,1) - il(:,2)).^2);
-                end;
+                end
         X = ranks(X);
-        end;
+        end
         R = 1 - 6 * R ./ (n.*(n.*n-1));
 
-elseif strcmp(lower(Mode(1:7)),'partial');
+elseif strcmp(lower(Mode(1:7)),'partial')
         fprintf(2,'Error CORRCOEF: use PARTCORRCOEF \n',Mode);
 
-        return;
+        return
 
-elseif strcmp(lower(Mode(1:7)),'kendall');
+elseif strcmp(lower(Mode(1:7)),'kendall')
         fprintf(2,'Error CORRCOEF: mode ''%s'' not implemented yet.\n',Mode);
 
-        return;
+        return
 else
         fprintf(2,'Error CORRCOEF: unknown mode ''%s''\n',Mode);
-end;
+end
 
-if (NARG<2),
+if (NARG<2)
         warning(FLAG_WARNING);  % restore warning status
-        return;
-end;
+        return
+end
 
 
 % CONFIDENCE INTERVAL
 if isfield(mode,'alpha')
     alpha = mode.alpha;
-elseif exist('flag_implicit_significance','file'),
+elseif exist('flag_implicit_significance','file')
         alpha = flag_implicit_significance;
 else
     alpha = 0.01;
-end;
+end
 % fprintf(1,'CORRCOEF: confidence interval is based on alpha=%f\n',alpha);
 
 
@@ -327,21 +327,21 @@ tmp = 1 - R.*R;
 tmp(tmp<0) = 0;		% prevent tmp<0 i.e. imag(t)~=0
 t   = R.*sqrt(max(NN-2,0)./tmp);
 
-if exist('t_cdf','file');
+if exist('t_cdf','file')
         sig = t_cdf(t,NN-2);
-elseif exist('tcdf','file')>1;
+elseif exist('tcdf','file')>1
         sig = tcdf(t,NN-2);
 else
         fprintf('CORRCOEF: significance test not completed because of missing TCDF-function\n')
         sig = repmat(nan,size(R));
-end;
+end
 sig  = 2 * min(sig,1 - sig);
 
 
-if NARG<3,
+if NARG<3
     warning(FLAG_WARNING);  % restore warning status
-        return;
-end;
+        return
+end
 
 
 tmp = R;
@@ -356,11 +356,11 @@ ci2 = tanh(z+sz);
 %ci1(isnan(ci1))=R(isnan(ci1));	% in case of isnan(ci), the interval limits are exactly the R value
 %ci2(isnan(ci2))=R(isnan(ci2));
 
-if (NARG<5) || ~YESNAN,
+if (NARG<5) || ~YESNAN
     nan_sig = repmat(NaN,size(R));
     warning(FLAG_WARNING);  % restore warning status
-    return;
-end;
+    return
+end
 
 %%%%% ----- check independence of NaNs (missing values) -----
 [nan_R, nan_sig] = corrcoef(X,double(isnan(X)));
@@ -370,7 +370,7 @@ nan_sig(isnan(nan_R)) = nan;
 % remove diagonal elements, because these have not any meaning %
 nan_R(isnan(nan_R)) = 0;
 
-if 0, any(nan_sig(:) < alpha),
+if 0, any(nan_sig(:) < alpha)
         tmp = nan_sig(:);			% Hack to skip NaN's in MIN(X)
         min_sig = min(tmp(~isnan(tmp)));    % Necessary, because Octave returns NaN rather than min(X) for min(NaN,X)
         fprintf(1,'CORRCOFF Warning: Missing Values (i.e. NaNs) are not independent of data (p-value=%f)\n', min_sig);
@@ -378,10 +378,9 @@ if 0, any(nan_sig(:) < alpha),
         fprintf(1,'   The null-hypotheses (NaNs are uncorrelated) is rejected for the following parameter pair(s).\n');
         [ix,iy] = find(nan_sig < alpha);
         disp([ix,iy])
-end;
+end
 
 %%%%% ----- end of independence check ------
 
 warning(FLAG_WARNING);  % restore warning status
-return;
 
diff --git a/matlab/missing/corrcoef/flag_implicit_skip_nan.m b/matlab/missing/corrcoef/flag_implicit_skip_nan.m
index 409b9f696..c86580d56 100644
--- a/matlab/missing/corrcoef/flag_implicit_skip_nan.m
+++ b/matlab/missing/corrcoef/flag_implicit_skip_nan.m
@@ -52,15 +52,15 @@ persistent FLAG_implicit_skip_nan;
 %% if strcmp(version,'3.6'), FLAG_implicit_skip_nan=(1==1); end;	%% hack for the use with Freemat3.6
 
 %%% set DEFAULT value of FLAG
-if isempty(FLAG_implicit_skip_nan),
+if isempty(FLAG_implicit_skip_nan)
     FLAG_implicit_skip_nan = (1==1); %logical(1); % logical.m not available on 2.0.16
-end;
+end
 
 FLAG = FLAG_implicit_skip_nan;
-if nargin>0,
+if nargin>0
     FLAG_implicit_skip_nan = (i~=0); %logical(i); %logical.m not available in 2.0.16
     if (~i)
         warning('flag_implicit_skipnan(0): You are warned!!! You have turned off skipping NaN in sumskipnan. This is not recommended. Make sure you really know what you do.')
-    end;
-end;
+    end
+end
 
diff --git a/matlab/missing/corrcoef/sumskipnan.m b/matlab/missing/corrcoef/sumskipnan.m
index 78f8ecbc1..1c53fee6d 100644
--- a/matlab/missing/corrcoef/sumskipnan.m
+++ b/matlab/missing/corrcoef/sumskipnan.m
@@ -56,12 +56,12 @@ function [o,count,SSQ] = sumskipnan(x, DIM, W)
 
 global FLAG_NANS_OCCURED;
 
-if nargin<2,
+if nargin<2
         DIM = [];
-end;
-if nargin<3,
+end
+if nargin<3
         W = [];
-end;
+end
 
 % an efficient implementation in C of the following lines
 % could significantly increase performance
@@ -78,19 +78,19 @@ end;
 %		o3    += tmp.*tmp;
 %       };
 
-if isempty(DIM),
+if isempty(DIM)
         DIM = find(size(x)>1,1);
-        if isempty(DIM), DIM = 1; end;
+        if isempty(DIM), DIM = 1; end
 end
-if (DIM<1), DIM = 1; end; %% Hack, because min([])=0 for FreeMat v3.5
+if (DIM<1), DIM = 1; end %% Hack, because min([])=0 for FreeMat v3.5
 
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 % non-float data
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-if  (isempty(W) && (~(isa(x,'float') || isa(x,'double')))) || ~flag_implicit_skip_nan(), %%% skip always NaN's
+if  (isempty(W) && (~(isa(x,'float') || isa(x,'double')))) || ~flag_implicit_skip_nan() %%% skip always NaN's
     if ~isempty(W)
         error('SUMSKIPNAN: weighted sum of integers not supported, yet');
-    end;
+    end
     x = double(x);
     o = sum(x,DIM);
     if nargout>1
@@ -101,16 +101,16 @@ if  (isempty(W) && (~(isa(x,'float') || isa(x,'double')))) || ~flag_implicit_ski
         if nargout>2
             x = x.*x;
             SSQ = sum(x,DIM);
-        end;
-    end;
-    return;
-end;
+        end
+    end
+    return
+end
 
 if (length(size(x))<DIM)
     error('SUMSKIPNAN: DIM argument larger than number of dimensions of x');
 elseif ~isempty(W) && (size(x,DIM)~=numel(W))
     error('SUMSKIPNAN: size of weight vector does not match size(x,DIM)');
-end;
+end
 
 %% mex and oct files expect double
 x = double(x);
@@ -124,18 +124,18 @@ try
     %% using sumskipnan_mex.mex
 
     %% !!! hack: FLAG_NANS_OCCURED is an output argument, reserve memory !!!
-    if isempty(FLAG_NANS_OCCURED),
+    if isempty(FLAG_NANS_OCCURED)
         FLAG_NANS_OCCURED = logical(0);  % default value
-    end;
+    end
 
-    if (nargout<2),
+    if (nargout<2)
         o = sumskipnan_mex(real(x),DIM,FLAG_NANS_OCCURED,W);
         if (~isreal(x))
             io = sumskipnan_mex(imag(x),DIM,FLAG_NANS_OCCURED,W);
             o  = o + i*io;
-        end;
-        return;
-    elseif (nargout==2),
+        end
+        return
+    elseif (nargout==2)
         [o,count] = sumskipnan_mex(real(x),DIM,FLAG_NANS_OCCURED,W);
         if (~isreal(x))
             [io,icount] = sumskipnan_mex(imag(x),DIM,FLAG_NANS_OCCURED,W);
@@ -143,10 +143,10 @@ try
                 error('Number of NaNs differ for REAL and IMAG part');
             else
                 o  = o+i*io;
-            end;
-        end;
-        return;
-    elseif (nargout>=3),
+            end
+        end
+        return
+    elseif (nargout>=3)
         [o,count,SSQ] = sumskipnan_mex(real(x),DIM,FLAG_NANS_OCCURED,W);
         if (~isreal(x))
             [io,icount,iSSQ] = sumskipnan_mex(imag(x),DIM,FLAG_NANS_OCCURED,W);
@@ -155,23 +155,23 @@ try
             else
                 o  = o+i*io;
                 SSQ = SSQ+iSSQ;
-            end;
-        end;
-        return;
-    end;
-end;
+            end
+        end
+        return
+    end
+end
 
 if ~isempty(W)
     error('weighted sumskipnan requires sumskipnan_mex');
-end;
+end
 
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 % count non-NaN's
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-if nargout>1,
+if nargout>1
         count = sum(x==x,DIM);
     FLAG_NANS_OCCURED = any(count(:)<size(x,DIM));
-end;
+end
 
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 % replace NaN's with zero
@@ -179,10 +179,10 @@ end;
 x(x~=x) = 0;
 o = sum(x,DIM);
 
-if nargout>2,
+if nargout>2
         x = real(x).^2 + imag(x).^2;
         SSQ = sum(x,DIM);
-end;
+end
 
 %!assert(sumskipnan([1,2],1),[1,2])
 %!assert(sumskipnan([1,NaN],2),1)
diff --git a/matlab/missing/corrcoef/tcdf.m b/matlab/missing/corrcoef/tcdf.m
index c282e0a17..1901c4f7d 100644
--- a/matlab/missing/corrcoef/tcdf.m
+++ b/matlab/missing/corrcoef/tcdf.m
@@ -37,10 +37,10 @@ if all(size(x)==1)
 elseif all(size(n)==1)
     n = repmat(n,size(x));
 elseif all(size(x)==size(n))
-    ;	%% OK, do nothing
+    % OK, do nothing
 else
     error('size of input arguments must be equal or scalar')
-end;
+end
 
 % allocate memory
 p = zeros(size(x));
diff --git a/matlab/missing/ordeig/ordeig.m b/matlab/missing/ordeig/ordeig.m
index 6004fd86f..0cbcc8267 100644
--- a/matlab/missing/ordeig/ordeig.m
+++ b/matlab/missing/ordeig/ordeig.m
@@ -34,7 +34,7 @@ i = 1;
 while i <= n
     if i == n
         eigs(n) = t(n,n);
-        break;
+        break
     elseif t(i+1,i) == 0
         eigs(i) = t(i,i);
         i = i+1;
diff --git a/matlab/missing/stats/betainv.m b/matlab/missing/stats/betainv.m
index 8273fc356..a7300d1b1 100644
--- a/matlab/missing/stats/betainv.m
+++ b/matlab/missing/stats/betainv.m
@@ -84,7 +84,7 @@ if (any (k))
         end
         h = y_old - y_new;
         if (max (abs (h)) < sqrt (eps))
-            break;
+            break
         end
         y_old = y_new;
     end
diff --git a/matlab/missing/stats/corr.m b/matlab/missing/stats/corr.m
index 21cdda767..4f3ebfb7b 100644
--- a/matlab/missing/stats/corr.m
+++ b/matlab/missing/stats/corr.m
@@ -84,12 +84,12 @@ if isscalar(x)
     else
         retval = NaN(size(y));    
     end
-    return;
+    return
 end
 
 if nargin==2 && isscalar(y)
     retval = NaN(size(x'));    
-    return;
+    return
 end
 
 n = size (x, 1);
diff --git a/matlab/missing/stats/gaminv.m b/matlab/missing/stats/gaminv.m
index e879616c4..96c4a0a3f 100644
--- a/matlab/missing/stats/gaminv.m
+++ b/matlab/missing/stats/gaminv.m
@@ -76,7 +76,7 @@ if (any (k))
             h = y_old - y_new;
         end
         if (max (abs (h)) < sqrt (eps))
-            break;
+            break
         end
         y_old = y_new;
     end
diff --git a/matlab/mode_check.m b/matlab/mode_check.m
index 3217dbd12..ac4497249 100644
--- a/matlab/mode_check.m
+++ b/matlab/mode_check.m
@@ -58,13 +58,13 @@ function mode_check(fun,x,hessian_mat,DynareDataset,DatasetInfo,DynareOptions,Mo
 % along with Dynare.  If not, see <http://www.gnu.org/licenses/>.
 
 TeX = DynareOptions.TeX;
-if ~isempty(hessian_mat);
+if ~isempty(hessian_mat)
     [ s_min, k ] = min(diag(hessian_mat));
 end
 
 fval = feval(fun,x,DynareDataset,DatasetInfo,DynareOptions,Model,EstimatedParameters,BayesInfo,BoundsInfo,DynareResults);
 
-if ~isempty(hessian_mat);
+if ~isempty(hessian_mat)
     skipline()
     disp('MODE CHECK')
     skipline()
@@ -85,13 +85,13 @@ if TeX && any(strcmp('eps',cellstr(DynareOptions.graph_format)))
 end
 
 ll = DynareOptions.mode_check.neighbourhood_size;
-if isinf(ll),
+if isinf(ll)
     DynareOptions.mode_check.symmetric_plots = 0;
 end
 
 mcheck = struct('cross',struct(),'emode',struct());
 
-for plt = 1:nbplt,
+for plt = 1:nbplt
     if TeX
         NAMES = [];
         TeXNAMES = [];
@@ -134,7 +134,7 @@ for plt = 1:nbplt,
         z1 = l1:((x(kk)-l1)/(DynareOptions.mode_check.number_of_points/2)):x(kk);
         z2 = x(kk):((l2-x(kk))/(DynareOptions.mode_check.number_of_points/2)):l2;
         z  = union(z1,z2);
-        if DynareOptions.mode_check.nolik==0,
+        if DynareOptions.mode_check.nolik==0
             y = zeros(length(z),2);
             dy = priordens(xx,BayesInfo.pshape,BayesInfo.p6,BayesInfo.p7,BayesInfo.p3,BayesInfo.p4);
         end
@@ -174,7 +174,7 @@ for plt = 1:nbplt,
         hold off
         drawnow
     end
-    if DynareOptions.mode_check.nolik==0,
+    if DynareOptions.mode_check.nolik==0
         if isoctave
             axes('outerposition',[0.3 0.93 0.42 0.07],'box','on'),
         else
diff --git a/matlab/model_diagnostics.m b/matlab/model_diagnostics.m
index 32a01725d..80854f499 100644
--- a/matlab/model_diagnostics.m
+++ b/matlab/model_diagnostics.m
@@ -67,7 +67,7 @@ end
 info=test_for_deep_parameters_calibration(M);
 if info
     problem_dummy=1;
-end;
+end
 
 % check if ys is steady state
 options.debug=1; %locally set debug option to 1
@@ -83,7 +83,7 @@ if check1(1)
     if any(isinf(dr.ys))
         disp(['MODEL_DIAGNOSTICS: Steady state contains Inf'])
     end
-    return;
+    return
 end
 
 if ~isreal(dr.ys)
@@ -210,7 +210,7 @@ if ~options.block
         else
             [junk,jacobia_] = feval([M.fname '_dynamic'],z(iyr0),exo_simul, ...
                 M.params, dr.ys, it_);
-        end;
+        end
     elseif options.order >= 2
         if (options.bytecode)
             [chck, junk, loc_dr] = bytecode('dynamic','evaluate', z,exo_simul, ...
@@ -220,7 +220,7 @@ if ~options.block
             [junk,jacobia_,hessian1] = feval([M.fname '_dynamic'],z(iyr0),...
                 exo_simul, ...
                 M.params, dr.ys, it_);
-        end;
+        end
         if options.use_dll
             % In USE_DLL mode, the hessian is in the 3-column sparse representation
             hessian1 = sparse(hessian1(:,1), hessian1(:,2), hessian1(:,3), ...
diff --git a/matlab/model_info.m b/matlab/model_info.m
index d99ca4807..4ceccd01b 100644
--- a/matlab/model_info.m
+++ b/matlab/model_info.m
@@ -1,4 +1,4 @@
-function model_info(varargin);
+function model_info(varargin)
 %function model_info;
 
 % Copyright (C) 2008-2012 Dynare Team
@@ -23,12 +23,12 @@ if sum(strcmp(varargin,'static')) > 0
     static_ = 1;
 else
     static_ = 0;
-end;
+end
 if sum(strcmp(varargin,'incidence')) > 0
     incidence = 1;
 else
     incidence = 0;
-end;
+end
 if static_
         fprintf('                                          Informations about %s (static model)\n',M_.fname);
         block_structre_str = 'block_structure_stat';
@@ -37,13 +37,13 @@ if static_
         fprintf('                                          Informations about %s (dynamic model)\n',M_.fname);
         block_structre_str = 'block_structure';
         nb_leadlag = 3;
-    end;
+    end
 if(isfield(M_,block_structre_str))
     if static_
         block_structure = M_.block_structure_stat;
     else
         block_structure = M_.block_structure;
-    end;
+    end
     fprintf(strcat('                                          ===================',char(ones(1,length(M_.fname))*'='),'\n\n'));
     nb_blocks=length(block_structure.block);
     fprintf('The model has %d equations and is decomposed in %d blocks as follow:\n',M_.endo_nbr,nb_blocks);
@@ -54,15 +54,15 @@ if(isfield(M_,block_structre_str))
         size_block=length(block_structure.block(i).equation);
         if(i>1)
             fprintf('|------------|------------|--------------------------------|----------------|---------------------------------|\n');
-        end;
+        end
         for j=1:size_block
             if(j==1)
                 fprintf('| %10d | %10d | %30s | %14d | %-6d %24s |\n',i,size_block,Sym_type(block_structure.block(i).Simulation_Type),block_structure.block(i).equation(j),block_structure.block(i).variable(j),M_.endo_names(block_structure.block(i).variable(j),:));
             else
                 fprintf('| %10s | %10s | %30s | %14d | %-6d %24s |\n','','','',block_structure.block(i).equation(j),block_structure.block(i).variable(j),M_.endo_names(block_structure.block(i).variable(j),:));
-            end;
-        end;
-    end;
+            end
+        end
+    end
     fprintf('===============================================================================================================\n');
     fprintf('\n');
     if static_
@@ -71,16 +71,16 @@ if(isfield(M_,block_structre_str))
             IM=sortrows(block_structure.incidence.sparse_IM,2);
         else
             IM=[];
-        end;
+        end
         size_IM=size(IM,1);
         last=99999999;
         for i=1:size_IM
             if(last~=IM(i,2))
                 fprintf('\n%-30s',M_.endo_names(IM(i,2),:));
-            end;
+            end
             fprintf(' %5d',IM(i,1));
             last=IM(i,2);
-        end;
+        end
         fprintf('\n\n');
     else
         for k=1:M_.maximum_endo_lag+M_.maximum_endo_lead+1
@@ -90,24 +90,24 @@ if(isfield(M_,block_structre_str))
                 fprintf('%-30s %s %d','the variable','is used in equations with lag ',M_.maximum_endo_lag+1-k);
             else
                 fprintf('%-30s %s %d','the variable','is used in equations with lead ',k-(M_.maximum_endo_lag+1));
-            end;
+            end
             if(size(block_structure.incidence(k).sparse_IM,1)>0)
                 IM=sortrows(block_structure.incidence(k).sparse_IM,2);
             else
                 IM=[];
-            end;
+            end
             size_IM=size(IM,1);
             last=99999999;
             for i=1:size_IM
                 if(last~=IM(i,2))
                     fprintf('\n%-30s',M_.endo_names(IM(i,2),:));
-                end;
+                end
                 fprintf(' %5d',IM(i,1));
                 last=IM(i,2);
-            end;
+            end
             fprintf('\n\n');
-        end;
-    end;
+        end
+    end
     
     %printing the gross incidence matrix
     IM_star = char([kron(ones(M_.endo_nbr, M_.endo_nbr-1), double(blanks(3))) double(blanks(M_.endo_nbr)')]);
@@ -118,9 +118,9 @@ if(isfield(M_,block_structre_str))
                 IM_star(block_structure.incidence(i).sparse_IM(j,1), 3 * (block_structure.incidence(i).sparse_IM(j,2) - 1) + 1) = 'X';
             else
                 IM_star(block_structure.incidence(i).sparse_IM(j,1), 3 * (block_structure.incidence(i).sparse_IM(j,2) - 1) + 1) = '1';
-            end;
-        end;
-    end;
+            end
+        end
+    end
     seq = 1: M_.endo_nbr;
     blank = [ blanks(size(M_.endo_names,2)); blanks(size(M_.endo_names,2))];
     for i = 1:M_.endo_nbr
@@ -128,8 +128,8 @@ if(isfield(M_,block_structre_str))
             var_names = [blank; M_.endo_names(i,:)];
         else
             var_names = [var_names; blank; M_.endo_names(i,:)];
-        end;
-    end;
+        end
+    end
     if incidence
         topp = [char(kron(double(blanks(ceil(log10(M_.endo_nbr)))),ones(size(M_.endo_names,2),1))) var_names' ];
         bott = [int2str(seq') blanks(M_.endo_nbr)' blanks(M_.endo_nbr)' IM_star];
@@ -145,9 +145,9 @@ if(isfield(M_,block_structre_str))
         cur_block = 1;
         for i = 1:M_.endo_nbr
             past_block = cur_block;
-            while ismember(block_structure.variable_reordered(i), block_structure.block(cur_block).variable) == 0;
+            while ismember(block_structure.variable_reordered(i), block_structure.block(cur_block).variable) == 0
                 cur_block = cur_block + 1;
-            end;
+            end
             if i == 1
                 var_names = [blank; M_.endo_names(block_structure.variable_reordered(i),:)];
             else
@@ -156,8 +156,8 @@ if(isfield(M_,block_structre_str))
                 else
                     var_names = [var_names; blank; M_.endo_names(block_structure.variable_reordered(i),:)];
                 end
-            end;
-        end;
+            end
+        end
         topp = [char(kron(double(blanks(ceil(log10(M_.endo_nbr)))),ones(size(M_.endo_names,2),1))) var_names' ];
         n_state_var = length(M_.state_var);
         IM_state_var = zeros(n_state_var, n_state_var);
@@ -172,38 +172,38 @@ if(isfield(M_,block_structre_str))
                     [tfi, loci] = ismember(block_structure.incidence(i).sparse_IM(j,1), state_equation);
                     if tfi
                         IM_state_var(loci, loc) = 1;
-                    end;
+                    end
                 else
                     IM_star_reordered(eq(block_structure.incidence(i).sparse_IM(j,1)), 3 * (va(block_structure.incidence(i).sparse_IM(j,2)) - 1) + 1) = '1';
-                end;
-            end;
-        end;
+                end
+            end
+        end
         fprintf('1: non nul element, X: non nul element related to a state variable\n');
         
         cur_block = 1;
         i_last = 0;
         block = {};
-        for i = 1:n_state_var;
+        for i = 1:n_state_var
             past_block = cur_block;
-            while ismember(M_.state_var(i), block_structure.block(cur_block).variable) == 0;
+            while ismember(M_.state_var(i), block_structure.block(cur_block).variable) == 0
                 cur_block = cur_block + 1;
-            end;
+            end
             if (past_block ~= cur_block) || (past_block == cur_block && i == n_state_var)
                 block(past_block).IM_state_var(1:(i - 1 - i_last), 1:i - 1) = IM_state_var(i_last+1:i - 1, 1:i - 1);
                 i_last = i - 1;
-            end;
-        end;
+            end
+        end
         cur_block = 1;
         for i = 1:M_.endo_nbr
             past_block = cur_block;
-            while ismember(block_structure.variable_reordered(i), block_structure.block(cur_block).variable) == 0;
+            while ismember(block_structure.variable_reordered(i), block_structure.block(cur_block).variable) == 0
                 cur_block = cur_block + 1;
-            end;
+            end
             if past_block ~= cur_block
                 for j = 1:i-1
                    IM_star_reordered(j, 3 * (i - 1) - 1) = '|';
-                end;
-            end;
+                end
+            end
         end
         
         bott = [int2str(block_structure.equation_reordered') blanks(M_.endo_nbr)' blanks(M_.endo_nbr)' IM_star_reordered];
@@ -211,10 +211,10 @@ if(isfield(M_,block_structre_str))
         fprintf('                                          ==========================\n');
         disp([topp; bott]);
         fprintf('1: non nul element, X: non nul element related to a state variable\n');
-     end;
+     end
 else
     fprintf('There is no block decomposition of the model.\nUse ''block'' model''s option.\n');
-end;
+end
 
 function ret=Sym_type(type)
 UNKNOWN=0;
@@ -229,32 +229,32 @@ SOLVE_TWO_BOUNDARIES_COMPLETE=8;
 EVALUATE_FORWARD_R=9;
 EVALUATE_BACKWARD_R=10;
 switch (type)
-  case (UNKNOWN),
+  case (UNKNOWN)
     ret='UNKNOWN                     ';
-  case {EVALUATE_FORWARD,EVALUATE_FORWARD_R},
+  case {EVALUATE_FORWARD,EVALUATE_FORWARD_R}
     ret='EVALUATE FORWARD            ';
-  case {EVALUATE_BACKWARD,EVALUATE_BACKWARD_R},
+  case {EVALUATE_BACKWARD,EVALUATE_BACKWARD_R}
     ret='EVALUATE BACKWARD            ';
-  case SOLVE_FORWARD_SIMPLE,
+  case SOLVE_FORWARD_SIMPLE
     ret='SOLVE FORWARD SIMPLE        ';
-  case SOLVE_BACKWARD_SIMPLE,
+  case SOLVE_BACKWARD_SIMPLE
     ret='SOLVE BACKWARD SIMPLE        ';
-  case SOLVE_TWO_BOUNDARIES_SIMPLE,
+  case SOLVE_TWO_BOUNDARIES_SIMPLE
     ret='SOLVE TWO BOUNDARIES SIMPLE  ';
-  case SOLVE_FORWARD_COMPLETE,
+  case SOLVE_FORWARD_COMPLETE
     ret='SOLVE FORWARD COMPLETE      ';
-  case SOLVE_BACKWARD_COMPLETE,
+  case SOLVE_BACKWARD_COMPLETE
     ret='SOLVE BACKWARD COMPLETE      ';
-  case SOLVE_TWO_BOUNDARIES_COMPLETE,
+  case SOLVE_TWO_BOUNDARIES_COMPLETE
     ret='SOLVE TWO BOUNDARIES COMPLETE';
-end;
+end
 
 
 function ret = barre(n)
 s = [];
-for i=1:n;
+for i=1:n
     s = [s '|'];
-end;
+end
 ret = s;
 
 
diff --git a/matlab/moment_function.m b/matlab/moment_function.m
index af0488a59..f10de3c5e 100644
--- a/matlab/moment_function.m
+++ b/matlab/moment_function.m
@@ -61,7 +61,7 @@ end
 
 if penalty>0
     flag = 0;
-    return;
+    return
 end
 
 save('estimated_parameters.mat','xparams');
diff --git a/matlab/myboxplot.m b/matlab/myboxplot.m
index fc54607e2..4a8b33658 100644
--- a/matlab/myboxplot.m
+++ b/matlab/myboxplot.m
@@ -33,7 +33,7 @@ if notched==1, notched=0.25; end
 a=1-notched;
 
 % ## figure out how many data sets we have
-if iscell(data), 
+if iscell(data) 
     nc = length(data);
 else
     %   if isvector(data), data = data(:); end
@@ -149,7 +149,7 @@ cap_y = whisker_y([1,1],:);
 
 mm=min(min(data));
 MM=max(max(data));
-if isnan(mm), mm=0; MM=0; end,
+if isnan(mm), mm=0; MM=0; end
 
 if vertical
     plot (quartile_x, quartile_y, 'b',  ...
@@ -171,7 +171,7 @@ else
     % % % % %     outliers2_y, outliers2_x, [symbol(2),"r;;"]);
 end
 
-if nargout,
+if nargout
     sout=s;
 end
 % % % endfunction
\ No newline at end of file
diff --git a/matlab/mydelete.m b/matlab/mydelete.m
index 13ef6ee9d..06795b084 100644
--- a/matlab/mydelete.m
+++ b/matlab/mydelete.m
@@ -18,16 +18,16 @@ function mydelete(fname,pname)
 % You should have received a copy of the GNU General Public License
 % along with Dynare.  If not, see <http://www.gnu.org/licenses/>.
 
-if nargin ==0,
+if nargin ==0
     disp('mydelete(fname)')
     return
 end
 
-if nargin ==1,
+if nargin ==1
     pname='';
 end
 
 file_to_delete = dir([pname,fname]);
-for j=1:length(file_to_delete),
+for j=1:length(file_to_delete)
     delete([pname,file_to_delete(j).name]);
 end
diff --git a/matlab/occbin/call_solve_one_constraint.m b/matlab/occbin/call_solve_one_constraint.m
index b4ec1baed..c613b5034 100755
--- a/matlab/occbin/call_solve_one_constraint.m
+++ b/matlab/occbin/call_solve_one_constraint.m
@@ -1,5 +1,5 @@
 % Solve model, generate model IRFs
-[zdatalinear zdatapiecewise zdatass oobase_ Mbase_ ] = ...
+[zdatalinear, zdatapiecewise, zdatass, oobase_, Mbase_ ] = ...
          solve_one_constraint(modnam,modnamstar,...
                               constraint, constraint_relax,...
                               shockssequence,irfshock,nperiods,maxiter);
diff --git a/matlab/occbin/call_solve_two_constraints.m b/matlab/occbin/call_solve_two_constraints.m
index b782e6db7..3adda90d7 100755
--- a/matlab/occbin/call_solve_two_constraints.m
+++ b/matlab/occbin/call_solve_two_constraints.m
@@ -1,4 +1,4 @@
-[zdatalinear zdatapiecewise zdatass oobase_ Mbase_] = solve_two_constraints(...
+[zdatalinear, zdatapiecewise, zdatass, oobase_, Mbase_] = solve_two_constraints(...
                  modnam_00,modnam_10,modnam_01,modnam_11,...
                  constraint1, constraint2,...
                  constraint_relax1, constraint_relax2,...
diff --git a/matlab/occbin/get_deriv.m b/matlab/occbin/get_deriv.m
index 24f1b42ae..d1fe78032 100755
--- a/matlab/occbin/get_deriv.m
+++ b/matlab/occbin/get_deriv.m
@@ -77,7 +77,7 @@ for i=1:nlea_cols
 end
 
  
-for i = 1:M_.exo_nbr;
+for i = 1:M_.exo_nbr
     j(:,i) =g1(:,i+ny);
 end
 
diff --git a/matlab/occbin/get_pq.m b/matlab/occbin/get_pq.m
index 5caab79af..2924eacf5 100755
--- a/matlab/occbin/get_pq.m
+++ b/matlab/occbin/get_pq.m
@@ -1,4 +1,4 @@
-function [p,q]=get_pq(dr_,nstatic,nfwrd);
+function [p,q]=get_pq(dr_,nstatic,nfwrd)
 
 nvars = size(dr_.ghx,1);
 nshocks = size(dr_.ghu,2);
diff --git a/matlab/occbin/makechart.m b/matlab/occbin/makechart.m
index a3801e956..c3ea7719e 100755
--- a/matlab/occbin/makechart.m
+++ b/matlab/occbin/makechart.m
@@ -49,9 +49,9 @@ for i = 1:nvars
     h1=plot(xvalues,zdata1(:,i),'b-','linewidth',2); hold on
     h1=plot(xvalues,zdata2(:,i),'r--','linewidth',2); hold on
     h2=plot(xvalues,zdata3(:,i),'b-','LineWidth',3);
-    [x0 x1 y10 y11] = pickaxes(xvalues,zdata1(:,i));
-    [x0 x1 y20 y21] = pickaxes(xvalues,zdata2(:,i));
-    [x0 x1 y30 y31] = pickaxes(xvalues,zdata3(:,i));
+    [x0, x1, y10, y11] = pickaxes(xvalues,zdata1(:,i));
+    [x0, x1, y20, y21] = pickaxes(xvalues,zdata2(:,i));
+    [x0, x1, y30, y31] = pickaxes(xvalues,zdata3(:,i));
     y0 = min([y10,y20,y30]);
     y1 = max([y11,y21,y31]);
     if y0==y1
diff --git a/matlab/occbin/makechart9.m b/matlab/occbin/makechart9.m
index c6e65afcd..8f9ae5479 100755
--- a/matlab/occbin/makechart9.m
+++ b/matlab/occbin/makechart9.m
@@ -72,10 +72,10 @@ elseif (nvars==5 | nvars ==6)
 elseif (nvars==7 | nvars==8)
     nrows = 4;
     ncols = 2;
-elseif nvars>8 & nvars<=12;
+elseif nvars>8 & nvars<=12
     nrows = 3;
     ncols = 4;
-elseif nvars>12 & nvars<=15;
+elseif nvars>12 & nvars<=15
     nrows = 5;
     ncols = 3;
 else 
@@ -92,13 +92,13 @@ for i = 1:nvars
         xvalues,zdata5(:,i),'g',...
         xvalues,zdata6(:,i),'c',...
         xvalues,zdata7(:,i),'y');
-    [x0 x1 y10 y11] = pickaxes(xvalues,zdata1(:,i));
-    [x0 x1 y20 y21] = pickaxes(xvalues,zdata2(:,i));
-    [x0 x1 y30 y31] = pickaxes(xvalues,zdata3(:,i));
-    [x0 x1 y40 y41] = pickaxes(xvalues,zdata4(:,i));
-    [x0 x1 y50 y51] = pickaxes(xvalues,zdata5(:,i));
-    [x0 x1 y60 y61] = pickaxes(xvalues,zdata6(:,i));
-    [x0 x1 y70 y71] = pickaxes(xvalues,zdata7(:,i));
+    [x0, x1, y10, y11] = pickaxes(xvalues,zdata1(:,i));
+    [x0, x1, y20, y21] = pickaxes(xvalues,zdata2(:,i));
+    [x0, x1, y30, y31] = pickaxes(xvalues,zdata3(:,i));
+    [x0, x1, y40, y41] = pickaxes(xvalues,zdata4(:,i));
+    [x0, x1, y50, y51] = pickaxes(xvalues,zdata5(:,i));
+    [x0, x1, y60, y61] = pickaxes(xvalues,zdata6(:,i));
+    [x0, x1, y70, y71] = pickaxes(xvalues,zdata7(:,i));
      grid on
     y0 = min([y10,y20,y30,y40,y50,y60,y70]);
     y1 = max([y11,y21,y31,y41,y51,y61,y71]);
diff --git a/matlab/occbin/map_regime.m b/matlab/occbin/map_regime.m
index a3ed88b47..1c84871bd 100755
--- a/matlab/occbin/map_regime.m
+++ b/matlab/occbin/map_regime.m
@@ -1,4 +1,4 @@
-function [regime regimestart]=map_regimes(violvecbool)
+function [regime, regimestart]=map_regimes(violvecbool)
 
 nperiods = length(violvecbool)-1;
 
diff --git a/matlab/occbin/mkdatap_anticipated.m b/matlab/occbin/mkdatap_anticipated.m
index 524d3dd5d..6fef8c7f2 100755
--- a/matlab/occbin/mkdatap_anticipated.m
+++ b/matlab/occbin/mkdatap_anticipated.m
@@ -12,7 +12,7 @@ if nargin<16
     init=zeros(nvars,1);
 end
 
-if nargin<15;
+if nargin<15
     scalefactormod=1;
 end
 
diff --git a/matlab/occbin/mkdatap_anticipated_2constraints.m b/matlab/occbin/mkdatap_anticipated_2constraints.m
index b05c90d6d..85da740e5 100755
--- a/matlab/occbin/mkdatap_anticipated_2constraints.m
+++ b/matlab/occbin/mkdatap_anticipated_2constraints.m
@@ -16,7 +16,7 @@ if nargin<16
     init=zeros(nvars,1);
 end
 
-if nargin<15;
+if nargin<15
     scalefactormod=1;
 end
 
diff --git a/matlab/occbin/solve_no_constraint_noclear.m b/matlab/occbin/solve_no_constraint_noclear.m
index 309c5c546..0dab8c816 100755
--- a/matlab/occbin/solve_no_constraint_noclear.m
+++ b/matlab/occbin/solve_no_constraint_noclear.m
@@ -1,6 +1,6 @@
-function [zdata oobase_ Mbase_ ] = ...
+function [zdata, oobase_, Mbase_ ] = ...
     solve_no_constraint_noclear(modnam,...
-    shockssequence,irfshock,nperiods);
+    shockssequence,irfshock,nperiods)
 
 global M_ oo_
 
diff --git a/matlab/occbin/solve_one_constraint.m b/matlab/occbin/solve_one_constraint.m
index c446f4c40..c8a7c2494 100755
--- a/matlab/occbin/solve_one_constraint.m
+++ b/matlab/occbin/solve_one_constraint.m
@@ -24,7 +24,7 @@
 % 6/17/2013 -- Luca replaced external .m file setss.m
 
 
-function [zdatalinear_ zdatapiecewise_ zdatass_ oobase_ Mbase_  ] = ...
+function [zdatalinear_, zdatapiecewise_, zdatass_, oobase_, Mbase_  ] = ...
     solve_one_constraint(modnam_,modnamstar_,...
     constraint_, constraint_relax_,...
     shockssequence_,irfshock_,nperiods_,maxiter_,init_)
@@ -140,7 +140,7 @@ for ishock_ = 1:nshocks_
         iter_ = iter_ +1;
         
         % analyze when each regime starts based on current guess
-        [regime regimestart]=map_regime(violvecbool_);
+        [regime, regimestart]=map_regime(violvecbool_);
         
         
         
diff --git a/matlab/occbin/solve_two_constraints.m b/matlab/occbin/solve_two_constraints.m
index dfca403a2..ff5f734ed 100755
--- a/matlab/occbin/solve_two_constraints.m
+++ b/matlab/occbin/solve_two_constraints.m
@@ -29,7 +29,7 @@
 % to be processed.
 % 6/17/2013 -- Luca replaced external .m file setss.m
 
-function [ zdatalinear_ zdatapiecewise_ zdatass_ oo00_  M00_ ] = ...
+function [ zdatalinear_, zdatapiecewise_, zdatass_, oo00_ , M00_ ] = ...
   solve_two_constraints(modnam_00_,modnam_10_,modnam_01_,modnam_11_,...
     constrain1_, constrain2_,...
     constraint_relax1_, constraint_relax2_,...
@@ -220,8 +220,8 @@ for ishock_ = 1:nshocks
         
         % analyse violvec and isolate contiguous periods in the other
         % regime.
-        [regime1 regimestart1]=map_regime(violvecbool_(:,1));
-        [regime2 regimestart2]=map_regime(violvecbool_(:,2));
+        [regime1, regimestart1]=map_regime(violvecbool_(:,1));
+        [regime2, regimestart2]=map_regime(violvecbool_(:,2));
         
         
         [zdatalinear_]=mkdatap_anticipated_2constraints(nperiods_,decrulea,decruleb,...
diff --git a/matlab/occbin/tokenize.m b/matlab/occbin/tokenize.m
index f6e9f330c..b711ca082 100755
--- a/matlab/occbin/tokenize.m
+++ b/matlab/occbin/tokenize.m
@@ -28,7 +28,7 @@ else
     ndelims = length(posdelims);
     % build positions for substrings
     delims = zeros(ndelims+1,2);
-    for i=1:ndelims+1;
+    for i=1:ndelims+1
         if i==1
                 if posdelims(1) == 1
                    tokens = cellstr(source(1));
diff --git a/matlab/optimization/apprgrdn.m b/matlab/optimization/apprgrdn.m
index 9f16e4466..633cfbf9c 100644
--- a/matlab/optimization/apprgrdn.m
+++ b/matlab/optimization/apprgrdn.m
@@ -51,7 +51,7 @@ for i=1:n
     y(i)=x(i)+di(i);
     fi=feval(fun,y,varargin{:});
     if obj
-        if fi==f,
+        if fi==f
             for j=1:3
                 di(i)=di(i)*10;  y(i)=x(i)+di(i);
                 fi=feval(fun,y,varargin{:});
diff --git a/matlab/optimization/cmaes.m b/matlab/optimization/cmaes.m
index 833dbe9b2..8ec94e5ea 100644
--- a/matlab/optimization/cmaes.m
+++ b/matlab/optimization/cmaes.m
@@ -283,7 +283,7 @@ if nargin < 1 || isequal(fitfun, 'defaults') % pass default options
   if nargin > 1 % supplement second argument with default options
     xmin = getoptions(xstart, defopts);
   end
-  return;
+  return
 end
 
 if isequal(fitfun, 'displayoptions')
@@ -291,7 +291,7 @@ if isequal(fitfun, 'displayoptions')
  for name = names'
    disp([name{:} repmat(' ', 1, 20-length(name{:})) ': ''' defopts.(name{:}) '''']); 
  end
- return; 
+ return 
 end
 
 input.fitfun = fitfun; % record used input
@@ -378,7 +378,7 @@ if ~flgresume % not resuming a former run
 else % flgresume is true, do resume former run
   tmp = whos('-file', opts.SaveFilename);
   for i = 1:length(tmp)
-    if strcmp(tmp(i).name, 'localopts');
+    if strcmp(tmp(i).name, 'localopts')
       error('Saved variables include variable "localopts", please remove');
     end
   end
@@ -576,7 +576,7 @@ else % flgresume
     if any(lbounds>ubounds)
       error('lower bound found to be greater than upper bound');
     end
-    [xmean ti] = xintobounds(xmean, lbounds, ubounds); % just in case
+    [xmean, ti] = xintobounds(xmean, lbounds, ubounds); % just in case
     if any(ti)
       warning('Initial point was out of bounds, corrected');
     end
@@ -910,7 +910,7 @@ while isempty(stopflag)
   % non-parallel evaluation and remaining NaN-values
   % set also the reevaluated solution to NaN
   fitness.raw(lambda + find(isnan(fitness.raw(1:noiseReevals)))) = NaN;  
-  for k=find(isnan(fitness.raw)), 
+  for k=find(isnan(fitness.raw))
     % fitness.raw(k) = NaN; 
     tries = 0;
     % Resample, until fitness is not NaN
@@ -987,7 +987,7 @@ while isempty(stopflag)
       bnd.dfithist = [bnd.dfithist(2:end) val];
     end
 
-    [tx ti]  = xintobounds(xmean, lbounds, ubounds);
+    [tx, ti]  = xintobounds(xmean, lbounds, ubounds);
 
     % Set initial weights
     if bnd.iniphase 
@@ -1148,8 +1148,8 @@ while isempty(stopflag)
         % i-th longest becomes i-th shortest
         % TODO: this is not in compliance with the paper Hansen&Ros2010, 
         %       where simply arnorms = arnorms(end:-1:1) ? 
-        [arnorms idxnorms] = sort(sqrt(sum(arzneg.^2, 1))); 
-        [ignore idxnorms] = sort(idxnorms);  % inverse index 
+        [arnorms, idxnorms] = sort(sqrt(sum(arzneg.^2, 1))); 
+        [ignore, idxnorms] = sort(idxnorms);  % inverse index 
         arnormfacs = arnorms(end:-1:1) ./ arnorms; 
         % arnormfacs = arnorms(randperm(neg.mu)) ./ arnorms;
         arnorms = arnorms(end:-1:1); % for the record
@@ -1510,13 +1510,13 @@ while isempty(stopflag)
     while fid > 0
       strline = fgetl(fid); %fgets(fid, 300);
       if strline < 0 % fgets and fgetl returns -1 at end of file
-        break;
+        break
       end
       % 'stop filename' sets stopflag to manual
       str = sscanf(strline, ' %s %s', 2);
       if strcmp(str, ['stop' opts.LogFilenamePrefix]) 
         stopflag(end+1) = {'manual'};
-        break;
+        break
       end
       % 'skip filename run 3' skips a run, but not the last
       str = sscanf(strline, ' %s %s %s', 3);
@@ -1545,8 +1545,8 @@ while isempty(stopflag)
     if mod(countiter, verbosemodulo) < 1 ...
 	  || (verbosemodulo > 0 && isfinite(verbosemodulo) && ...
 	      (countiter < 3 || ~isempty(stopflag)))
-      [minstd minstdidx] = min(sigma*sqrt(diagC));
-      [maxstd maxstdidx] = max(sigma*sqrt(diagC));
+      [minstd, minstdidx] = min(sigma*sqrt(diagC));
+      [maxstd, maxstdidx] = max(sigma*sqrt(diagC));
       % format display nicely
       disp([repmat(' ',1,4-floor(log10(countiter))) ...
 	    num2str(countiter) ' , ' ...
@@ -1749,7 +1749,7 @@ end
 	|| any(strcmp(stopflag, 'maxfunevals')) ...
 	|| any(strcmp(stopflag, 'stoptoresume')) ...
 	|| any(strcmp(stopflag, 'manual'))
-    break; 
+    break
   end
 end % while irun <= Restarts
 
@@ -1839,10 +1839,10 @@ function opts=getoptions(inopts, defopts)
 
 if nargin < 2 || isempty(defopts) % no default options available
   opts=inopts;
-  return;
+  return
 elseif isempty(inopts) % empty inopts invoke default options
   opts = defopts;
-  return;
+  return
 elseif ~isstruct(defopts) % handle a single option value
   if isempty(inopts) 
     opts = defopts;
@@ -1851,7 +1851,7 @@ elseif ~isstruct(defopts) % handle a single option value
   else
     error('Input options are a struct, while default options are not');
   end
-  return;
+  return
 elseif ~isstruct(inopts) % no valid input options
   error('The options need to be a struct or empty');
 end
@@ -1989,7 +1989,7 @@ end
  
 % sort inar
 if nargin < 3 || isempty(idx)
-  [sar idx] = sort(inar);
+  [sar, idx] = sort(inar);
 else
   sar = inar(idx);
 end
@@ -2024,7 +2024,7 @@ end
 
 
 
-function [s ranks rankDelta] = local_noisemeasurement(arf1, arf2, lamreev, theta, cutlimit)
+function [s, ranks, rankDelta] = local_noisemeasurement(arf1, arf2, lamreev, theta, cutlimit)
 % function [s ranks rankDelta] = noisemeasurement(arf1, arf2, lamreev, theta)
 %
 % Input: 
@@ -2207,7 +2207,7 @@ manual_mode = 0;
   % plot fitness etc
   foffset = 1e-99;
   dfit = d.f(:,6)-min(d.f(:,6)); 
-  [ignore idxbest] = min(dfit);
+  [ignore, idxbest] = min(dfit);
   dfit(dfit<1e-98) = NaN;
   subplot(2,2,1); hold off; 
   dd = abs(d.f(:,7:8)) + foffset; 
@@ -2308,7 +2308,7 @@ manual_mode = 0;
   ax(2) = max(minxend, ax(2)); 
   axis(ax);
   % add some annotation lines
-  [ignore idx] = sort(d.std(end,6:end));
+  [ignore, idx] = sort(d.std(end,6:end));
   % choose no more than 25 indices 
   idxs = round(linspace(1, size(d.x,2)-5, min(size(d.x,2)-5, 25))); 
   yy = repmat(NaN, 2, size(d.std,2)-5);
@@ -2565,7 +2565,7 @@ function f=fbaluja(x)
 
 function f=fschwefel(x)
   f = 0;
-  for i = 1:size(x,1),
+  for i = 1:size(x,1)
     f = f+sum(x(1:i))^2;
   end
 
@@ -2662,7 +2662,7 @@ function f=fsharpR(x)
   f = abs(-x(1, :)).^2 + 100 * sqrt(sum(x(2:end,:).^2, 1));
   
 function f=frosen(x)
-  if size(x,1) < 2 error('dimension must be greater one'); end
+  if size(x,1) < 2, error('dimension must be greater one'); end
   N = size(x,1); 
   popsi = size(x,2); 
   f = 1e2*sum((x(1:end-1,:).^2 - x(2:end,:)).^2,1) + sum((x(1:end-1,:)-1).^2,1);
@@ -2704,7 +2704,7 @@ function f=fschwefelrosen2(x)
   f=sum((x(2:end).^2-x(1)).^2 + (x(2:end)-1).^2);
 
 function f=fdiffpow(x)
-  [N popsi] = size(x); if N < 2 error('dimension must be greater one'); end
+  [N, popsi] = size(x); if N < 2 error('dimension must be greater one'); end
 
   f = sum(abs(x).^repmat(2+10*(0:N-1)'/(N-1), 1, popsi), 1);
   f = sqrt(f); 
diff --git a/matlab/optimization/csminit1.m b/matlab/optimization/csminit1.m
index 1a0795195..4184af2df 100644
--- a/matlab/optimization/csminit1.m
+++ b/matlab/optimization/csminit1.m
@@ -216,7 +216,7 @@ else
                 end
             end
             lambda=lambda*factor;
-            if abs(lambda) > 1e20;
+            if abs(lambda) > 1e20
                 retcode = 5;
                 done =1;
             end
diff --git a/matlab/optimization/csminwel1.m b/matlab/optimization/csminwel1.m
index 52a018792..7b067a0a8 100644
--- a/matlab/optimization/csminwel1.m
+++ b/matlab/optimization/csminwel1.m
@@ -139,7 +139,7 @@ while ~done
         else
             if NumGrad
                 [g1, badg1]=get_num_grad(method,fcn,penalty,f1,x1,epsilon,varargin{:});
-            elseif ischar(grad),
+            elseif ischar(grad)
                 [g1, badg1] = grad(x1,varargin{:});
             else
                 [junk1,cost_flag,g1] = penalty_objective_function(x1,fcn,penalty,varargin{:});
@@ -166,7 +166,7 @@ while ~done
                 else
                     if NumGrad
                         [g2, badg2]=get_num_grad(method,fcn,penalty,f2,x2,epsilon,varargin{:});
-                    elseif ischar(grad),
+                    elseif ischar(grad)
                         [g2, badg2] = grad(x2,varargin{:});
                     else
                         [junk2,cost_flag,g2] = penalty_objective_function(x1,fcn,penalty,varargin{:});
@@ -198,7 +198,7 @@ while ~done
                         else
                             if NumGrad
                                 [g3, badg3]=get_num_grad(method,fcn,penalty,f3,x3,epsilon,varargin{:});
-                            elseif ischar(grad),
+                            elseif ischar(grad)
                                 [g3, badg3] = grad(x3,varargin{:});
                             else
                                 [junk3,cost_flag,g3] = penalty_objective_function(x1,fcn,penalty,varargin{:});
@@ -258,7 +258,7 @@ while ~done
         if nogh
             if NumGrad
                 [gh, badgh]=get_num_grad(method,fcn,penalty,fh,xh,epsilon,varargin{:});
-            elseif ischar(grad),
+            elseif ischar(grad)
                 [gh, badgh] = grad(xh,varargin{:});
             else
                 [junkh,cost_flag,gh] = penalty_objective_function(x1,fcn,penalty,varargin{:});
diff --git a/matlab/optimization/dynare_minimize_objective.m b/matlab/optimization/dynare_minimize_objective.m
index 30705f54a..4a99e7841 100644
--- a/matlab/optimization/dynare_minimize_objective.m
+++ b/matlab/optimization/dynare_minimize_objective.m
@@ -77,7 +77,7 @@ switch minimizer_algorithm
     if options_.silent_optimizer
         optim_options = optimset(optim_options,'display','off');
     end
-    if options_.analytic_derivation,
+    if options_.analytic_derivation
         optim_options = optimset(optim_options,'GradObj','on','TolX',1e-7);
     end
     [opt_par_values,fval,exitflag,output,lamdba,grad,hessian_mat] = ...
@@ -148,7 +148,7 @@ switch minimizer_algorithm
     if ~isempty(options_.optim_opt)
         eval(['optim_options = optimset(optim_options,' options_.optim_opt ');']);
     end
-    if options_.analytic_derivation,
+    if options_.analytic_derivation
         optim_options = optimset(optim_options,'GradObj','on');
     end
     if options_.silent_optimizer
diff --git a/matlab/optimization/gmhmaxlik.m b/matlab/optimization/gmhmaxlik.m
index 3710d8d65..b479a31a2 100644
--- a/matlab/optimization/gmhmaxlik.m
+++ b/matlab/optimization/gmhmaxlik.m
@@ -19,7 +19,7 @@ function [PostMode, HessianMatrix, Scale, ModeValue] = gmhmaxlik(fun, xinit, Hin
     
 % Set default options
 
-if ~isempty(Hinit);
+if ~isempty(Hinit)
     gmhmaxlikOptions.varinit = 'previous';
 else
     gmhmaxlikOptions.varinit = 'prior';
diff --git a/matlab/optimization/mr_gstep.m b/matlab/optimization/mr_gstep.m
index 605508d2c..f6533a5d9 100644
--- a/matlab/optimization/mr_gstep.m
+++ b/matlab/optimization/mr_gstep.m
@@ -29,7 +29,7 @@ function [f0, x, ig] = mr_gstep(h1,x,bounds,func0,penalty,htol0,Verbose,Save_fil
 % along with Dynare.  If not, see <http://www.gnu.org/licenses/>.
 
 n=size(x,1);
-if isempty(h1),
+if isempty(h1)
     h1=varargin{3}.gradient_epsilon*ones(n,1);
 end
 
@@ -39,7 +39,7 @@ if isempty(htol0)
 else
     htol = htol0;
 end
-if length(htol)==1,
+if length(htol)==1
     htol=htol*ones(n,1);
 end
 f0=penalty_objective_function(x,func0,penalty,varargin{:});
@@ -72,7 +72,7 @@ while i<n
         gg(i)=(f1(i)'-f_1(i)')./(2.*h1(i));
         hh(i) = 1/max(1.e-9,abs( (f1(i)+f_1(i)-2*f0)./(h1(i)*h1(i)) ));
         if gg(i)*(hh(i)*gg(i))/2 > htol(i)
-            [f0 x fc retcode] = csminit1(func0,x,penalty,f0,gg,0,diag(hh),Verbose,varargin{:});
+            [f0, x, fc, retcode] = csminit1(func0,x,penalty,f0,gg,0,diag(hh),Verbose,varargin{:});
             ig(i)=1;
             if Verbose
                 fprintf(['Done for param %s = %8.4f\n'],varargin{6}.name{i},x(i))
@@ -95,12 +95,12 @@ return
 function x = check_bounds(x,bounds)
 
 inx = find(x>=bounds(:,2));
-if ~isempty(inx),
+if ~isempty(inx)
     x(inx) = bounds(inx,2)-eps;
 end
 
 inx = find(x<=bounds(:,1));
-if ~isempty(inx),
+if ~isempty(inx)
     x(inx) = bounds(inx,1)+eps;
 end
 
diff --git a/matlab/optimization/mr_hessian.m b/matlab/optimization/mr_hessian.m
index eb1c0752e..4ffb3bdc3 100644
--- a/matlab/optimization/mr_hessian.m
+++ b/matlab/optimization/mr_hessian.m
@@ -67,7 +67,7 @@ n=size(x,1);
 h2=varargin{7}.ub-varargin{7}.lb;
 hmax=varargin{7}.ub-x;
 hmax=min(hmax,x-varargin{7}.lb);
-if isempty(ff0),
+if isempty(ff0)
     outer_product_gradient=0;
 else
     outer_product_gradient=1;
@@ -109,7 +109,7 @@ while i<n
     while (abs(dx(it))<0.5*hess_info.htol || abs(dx(it))>(3*hess_info.htol)) && icount<10 && ic==0
         icount=icount+1;
         if abs(dx(it))<0.5*hess_info.htol
-            if abs(dx(it)) ~= 0,
+            if abs(dx(it)) ~= 0
                 hess_info.h1(i)=min(max(1.e-10,0.3*abs(x(i))), 0.9*hess_info.htol/abs(dx(it))*hess_info.h1(i));
             else
                 hess_info.h1(i)=2.1*hess_info.h1(i);
@@ -147,8 +147,8 @@ while i<n
         end
     end
     f1(:,i)=fx;
-    if outer_product_gradient,
-        if any(isnan(ffx)) || isempty(ffx),
+    if outer_product_gradient
+        if any(isnan(ffx)) || isempty(ffx)
             ff1=ones(size(ff0)).*fx/length(ff0);
         else
             ff1=ffx;
@@ -157,8 +157,8 @@ while i<n
     xh1(i)=x(i)-hess_info.h1(i);
     [fx,exit_flag,ffx]=penalty_objective_function(xh1,func,penalty,varargin{:});
     f_1(:,i)=fx;
-    if outer_product_gradient,
-        if any(isnan(ffx)) || isempty(ffx),
+    if outer_product_gradient
+        if any(isnan(ffx)) || isempty(ffx)
             ff_1=ones(size(ff0)).*fx/length(ff0);
         else
             ff_1=ffx;
@@ -180,7 +180,7 @@ xh_1=xh1;
 
 gg=(f1'-f_1')./(2.*hess_info.h1);
 
-if outer_product_gradient,
+if outer_product_gradient
     if hflag==2
         gg=(f1'-f_1')./(2.*hess_info.h1);
         hessian_mat = zeros(size(f0,1),n*n);
diff --git a/matlab/optimization/newrat.m b/matlab/optimization/newrat.m
index 8085316d0..5bec31e7a 100644
--- a/matlab/optimization/newrat.m
+++ b/matlab/optimization/newrat.m
@@ -86,7 +86,7 @@ fval=fval0;
 outer_product_gradient=1;
 if isempty(hh)
     [dum, gg, htol0, igg, hhg, h1, hess_info]=mr_hessian(x,func0,penalty,flagit,htol,hess_info,varargin{:});
-    if isempty(dum),
+    if isempty(dum)
         outer_product_gradient=0;
         igg = 1e-4*eye(nx);
     else
@@ -154,7 +154,7 @@ while norm(gg)>gtol && check==0 && jit<nit
     if length(find(ig))<nx
         ggx=ggx*0;
         ggx(find(ig))=gg(find(ig));
-        if analytic_derivation,
+        if analytic_derivation
             hhx=hh;
         else
             hhx = reshape(dum,nx,nx);
@@ -195,7 +195,7 @@ while norm(gg)>gtol && check==0 && jit<nit
     if (fval0(icount)-fval)<ftol
         disp_verbose('No further improvement is possible!',Verbose)
         check=1;
-        if analytic_derivation,
+        if analytic_derivation
             [fvalx,exit_flag,gg,hh]=penalty_objective_function(xparam1,func0,penalty,varargin{:});
             hhg=hh;
             H = inv(hh);
@@ -233,7 +233,7 @@ while norm(gg)>gtol && check==0 && jit<nit
         disp_verbose(['Ftol          ',num2str(ftol)],Verbose)
         disp_verbose(['Htol          ',num2str(max(htol0))],Verbose)
         htol=htol_base;
-        if norm(x(:,icount)-xparam1)>1.e-12 && analytic_derivation==0,
+        if norm(x(:,icount)-xparam1)>1.e-12 && analytic_derivation==0
             try
                 if Save_files
                     save('m1.mat','x','fval0','nig','-append')
@@ -244,7 +244,7 @@ while norm(gg)>gtol && check==0 && jit<nit
                 end
             end
             [dum, gg, htol0, igg, hhg, h1, hess_info]=mr_hessian(xparam1,func0,penalty,flagit,htol,hess_info,varargin{:});
-            if isempty(dum),
+            if isempty(dum)
                 outer_product_gradient=0;
             end
             if max(htol0)>htol
@@ -253,7 +253,7 @@ while norm(gg)>gtol && check==0 && jit<nit
                 disp_verbose('Tolerance has to be relaxed',Verbose)
                 skipline()
             end
-            if ~outer_product_gradient,
+            if ~outer_product_gradient
                 H = bfgsi1(H,gg-g(:,icount),xparam1-x(:,icount),Verbose,Save_files);
                 hh=inv(H);
                 hhg=hh;
@@ -270,7 +270,7 @@ while norm(gg)>gtol && check==0 && jit<nit
                 end
                 H = igg;
             end
-        elseif analytic_derivation,
+        elseif analytic_derivation
             [fvalx,exit_flag,gg,hh]=penalty_objective_function(xparam1,func0,penalty,varargin{:});
             hhg=hh;
             H = inv(hh);
@@ -311,7 +311,7 @@ if norm(gg)<=gtol
     disp_verbose(['Estimation ended:'],Verbose)
     disp_verbose(['Gradient norm < ', num2str(gtol)],Verbose)
 end
-if check==1,
+if check==1
     disp_verbose(['Estimation successful.'],Verbose)
 end
 
@@ -321,11 +321,11 @@ return
 function x = check_bounds(x,bounds)
 
 inx = find(x>=bounds(:,2));
-if ~isempty(inx),
+if ~isempty(inx)
     x(inx) = bounds(inx,2)-eps;
 end
 
 inx = find(x<=bounds(:,1));
-if ~isempty(inx),
+if ~isempty(inx)
     x(inx) = bounds(inx,1)+eps;
 end
diff --git a/matlab/optimization/simplex_optimization_routine.m b/matlab/optimization/simplex_optimization_routine.m
index 58b3ff1b0..39785898a 100644
--- a/matlab/optimization/simplex_optimization_routine.m
+++ b/matlab/optimization/simplex_optimization_routine.m
@@ -396,7 +396,7 @@ while (func_count < max_func_calls) && (iter_count < max_iterations) && (simplex
         disp(['Crit. x:                  ' num2str(critX)])
         skipline()
     end
-    if verbose && max(abs(best_point-v(:,1)))>x_tolerance;
+    if verbose && max(abs(best_point-v(:,1)))>x_tolerance
         if verbose<2
             disp(['Simplex iteration number: ' int2str(simplex_iterations) '-' int2str(simplex_init) '-' int2str(simplex_algo_iterations)])
             disp(['Objective function value: ' num2str(fv(1))])
diff --git a/matlab/optimization/simpsa.m b/matlab/optimization/simpsa.m
index 260607a24..b389b37bd 100644
--- a/matlab/optimization/simpsa.m
+++ b/matlab/optimization/simpsa.m
@@ -77,11 +77,11 @@ function [X,FVAL,EXITFLAG,OUTPUT] = simpsa(FUN,X0,LB,UB,OPTIONS,varargin)
 
 % handle variable input arguments
 
-if nargin < 5,
+if nargin < 5
     OPTIONS = [];
-    if nargin < 4,
+    if nargin < 4
         UB = 1e5;
-        if nargin < 3,
+        if nargin < 3
             LB = -1e5;
         end
     end
@@ -89,22 +89,22 @@ end
 
 % check input arguments
 
-if ~ischar(FUN),
+if ~ischar(FUN)
     error('''FUN'' incorrectly specified in ''SIMPSA''');
 end
-if ~isfloat(X0),
+if ~isfloat(X0)
     error('''X0'' incorrectly specified in ''SIMPSA''');
 end
-if ~isfloat(LB),
+if ~isfloat(LB)
     error('''LB'' incorrectly specified in ''SIMPSA''');
 end
-if ~isfloat(UB),
+if ~isfloat(UB)
     error('''UB'' incorrectly specified in ''SIMPSA''');
 end
-if length(X0) ~= length(LB),
+if length(X0) ~= length(LB)
     error('''LB'' and ''X0'' have incompatible dimensions in ''SIMPSA''');
 end
-if length(X0) ~= length(UB),
+if length(X0) ~= length(UB)
     error('''UB'' and ''X0'' have incompatible dimensions in ''SIMPSA''');
 end
 
@@ -167,7 +167,7 @@ TEMP_LOOP_NUMBER = 1;
 % loop as described by Cardoso et al., 1996 (recommended)
 
 % therefore, the temperature is set to YBEST*1e5 in the first loop
-if isempty(OPTIONS.TEMP_START),
+if isempty(OPTIONS.TEMP_START)
     TEMP = abs(YBEST)*1e5;
 else
     TEMP = OPTIONS.TEMP_START;
@@ -195,7 +195,7 @@ nITERATIONS = 0;
 % temperature loop: run SIMPSA till stopping criterion is met
 % -----------------------------------------------------------
 
-while 1,
+while 1
     
     % detect if termination criterium was met
     % ---------------------------------------
@@ -203,23 +203,23 @@ while 1,
     % if a termination criterium was met, the value of EXITFLAG should have changed
     % from its default value of -2 to -1, 0, 1 or 2
     
-    if EXITFLAG ~= -2,
+    if EXITFLAG ~= -2
         break
     end
     
     % set MAXITERTEMP: maximum number of iterations at current temperature
     % --------------------------------------------------------------------
     
-    if TEMP_LOOP_NUMBER == 1,
+    if TEMP_LOOP_NUMBER == 1
         MAXITERTEMP = OPTIONS.MAX_ITER_TEMP_FIRST*NDIM;
         % The initial temperature is estimated (is requested) as described in 
         % Cardoso et al. (1996). Therefore, we need to store the number of 
         % successful and unsuccessful moves, as well as the increase in cost 
         % for the unsuccessful moves.
-        if isempty(OPTIONS.TEMP_START),
+        if isempty(OPTIONS.TEMP_START)
             [SUCCESSFUL_MOVES,UNSUCCESSFUL_MOVES,UNSUCCESSFUL_COSTS] = deal(0);
         end
-    elseif TEMP < OPTIONS.TEMP_END,
+    elseif TEMP < OPTIONS.TEMP_END
         TEMP = 0;
         MAXITERTEMP = OPTIONS.MAX_ITER_TEMP_LAST*NDIM;
     else
@@ -234,12 +234,12 @@ while 1,
     Y(1) = CALCULATE_COST(FUN,P(1,:),LB,UB,varargin{:});
     
     % if output function given then run output function to plot intermediate result
-    if ~isempty(OPTIONS.OUTPUT_FCN),
+    if ~isempty(OPTIONS.OUTPUT_FCN)
         feval(OPTIONS.OUTPUT_FCN,transpose(P(1,:)),Y(1));
     end
     
     % remaining vertices of simplex
-    for k = 1:NDIM,
+    for k = 1:NDIM
         % copy first vertex in new vertex
         P(k+1,:) = P(1,:);
         % alter new vertex
@@ -259,8 +259,8 @@ while 1,
     %  dimensions of vector Y: (NDIM+1) x 1
     
     % give user feedback if requested
-    if strcmp(OPTIONS.DISPLAY,'iter'),
-        if nITERATIONS == 0,
+    if strcmp(OPTIONS.DISPLAY,'iter')
+        if nITERATIONS == 0
             disp(' Nr Iter  Nr Fun Eval    Min function       Best function        TEMP           Algorithm Step');
         else
             disp(sprintf('%5.0f      %5.0f       %12.6g     %15.6g      %12.6g       %s',nITERATIONS,nFUN_EVALS,Y(1),YBEST,TEMP,'best point'));
@@ -280,7 +280,7 @@ while 1,
     
     % start
 
-    for ITERTEMP = 1:MAXITERTEMP,
+    for ITERTEMP = 1:MAXITERTEMP
         
         % add one to number of iterations
         nITERATIONS = nITERATIONS + 1;
@@ -315,12 +315,12 @@ while 1,
         OUTPUT.COSTS(nITERATIONS,:) = Y;
         OUTPUT.COST_BEST(nITERATIONS) = YBEST;
         
-        if strcmp(OPTIONS.DISPLAY,'iter'),
+        if strcmp(OPTIONS.DISPLAY,'iter')
             disp(sprintf('%5.0f      %5.0f       %12.6g     %15.6g      %12.6g       %s',nITERATIONS,nFUN_EVALS,Y(1),YBEST,TEMP,ALGOSTEP));
         end
         
         % if output function given then run output function to plot intermediate result
-        if ~isempty(OPTIONS.OUTPUT_FCN),
+        if ~isempty(OPTIONS.OUTPUT_FCN)
             feval(OPTIONS.OUTPUT_FCN,transpose(P(1,:)),Y(1));
         end
         
@@ -330,36 +330,36 @@ while 1,
         %% 3. no convergence,but maximum number of iterations has been reached
         %% 4. no convergence,but maximum time has been reached
             
-        if (abs(max(Y)-min(Y)) < OPTIONS.TOLFUN) && (TEMP_LOOP_NUMBER ~= 1),
-            if strcmp(OPTIONS.DISPLAY,'iter'),
+        if (abs(max(Y)-min(Y)) < OPTIONS.TOLFUN) && (TEMP_LOOP_NUMBER ~= 1)
+            if strcmp(OPTIONS.DISPLAY,'iter')
                 disp('Change in the objective function value less than the specified tolerance (TOLFUN).')
             end
             EXITFLAG = 1;
-            break;
+            break
         end
         
-        if (max(max(abs(P(2:NDIM+1,:)-P(1:NDIM,:)))) < OPTIONS.TOLX) && (TEMP_LOOP_NUMBER ~= 1),
-            if strcmp(OPTIONS.DISPLAY,'iter'),
+        if (max(max(abs(P(2:NDIM+1,:)-P(1:NDIM,:)))) < OPTIONS.TOLX) && (TEMP_LOOP_NUMBER ~= 1)
+            if strcmp(OPTIONS.DISPLAY,'iter')
                 disp('Change in X less than the specified tolerance (TOLX).')
             end
             EXITFLAG = 2;
-            break;
+            break
         end
         
-        if (nITERATIONS >= OPTIONS.MAX_ITER_TOTAL*NDIM) || (nFUN_EVALS >= OPTIONS.MAX_FUN_EVALS*NDIM*(NDIM+1)),
-            if strcmp(OPTIONS.DISPLAY,'iter'),
+        if (nITERATIONS >= OPTIONS.MAX_ITER_TOTAL*NDIM) || (nFUN_EVALS >= OPTIONS.MAX_FUN_EVALS*NDIM*(NDIM+1))
+            if strcmp(OPTIONS.DISPLAY,'iter')
                 disp('Maximum number of function evaluations or iterations reached.');
             end
             EXITFLAG = 0;
-            break;
+            break
         end
         
-        if toc/60 > OPTIONS.MAX_TIME,
-            if strcmp(OPTIONS.DISPLAY,'iter'),
+        if toc/60 > OPTIONS.MAX_TIME
+            if strcmp(OPTIONS.DISPLAY,'iter')
                 disp('Exceeded maximum time.');
             end
             EXITFLAG = -1;
-            break;
+            break
         end
         
         % begin a new iteration
@@ -369,11 +369,11 @@ while 1,
         [YFTRY,YTRY,PTRY] = AMOTRY(FUN,P,-1,LB,UB,varargin{:});
         
         %% check the result
-        if YFTRY <= YFLUCT(1),
+        if YFTRY <= YFLUCT(1)
             %% gives a result better than the best point,so try an additional
             %% extrapolation by a factor 2
             [YFTRYEXP,YTRYEXP,PTRYEXP] = AMOTRY(FUN,P,-2,LB,UB,varargin{:});
-            if YFTRYEXP < YFTRY,
+            if YFTRYEXP < YFTRY
                 P(end,:) = PTRYEXP;
                 Y(end) = YTRYEXP;
                 ALGOSTEP = 'reflection and expansion';
@@ -382,12 +382,12 @@ while 1,
                 Y(end) = YTRY;
                 ALGOSTEP = 'reflection';
             end
-        elseif YFTRY >= YFLUCT(NDIM),
+        elseif YFTRY >= YFLUCT(NDIM)
             %% the reflected point is worse than the second-highest, so look
             %% for an intermediate lower point, i.e., do a one-dimensional
             %% contraction
             [YFTRYCONTR,YTRYCONTR,PTRYCONTR] = AMOTRY(FUN,P,-0.5,LB,UB,varargin{:});
-            if YFTRYCONTR < YFLUCT(end),
+            if YFTRYCONTR < YFLUCT(end)
                 P(end,:) = PTRYCONTR;
                 Y(end) = YTRYCONTR;
                 ALGOSTEP = 'one dimensional contraction';
@@ -396,7 +396,7 @@ while 1,
                 %% around the lowest (best) point
                 X = ones(NDIM,NDIM)*diag(P(1,:));
                 P(2:end,:) = 0.5*(P(2:end,:)+X);
-                for k=2:NDIM,
+                for k=2:NDIM
                     Y(k) = CALCULATE_COST(FUN,P(k,:),LB,UB,varargin{:});
                 end
                 ALGOSTEP = 'multiple contraction';
@@ -412,10 +412,10 @@ while 1,
         % the number of successfull and unsuccesfull moves, and the average 
         % increase in cost associated with the unsuccessful moves
         
-        if TEMP_LOOP_NUMBER == 1 && isempty(OPTIONS.TEMP_START),
-            if Y(1) > Y(end),
+        if TEMP_LOOP_NUMBER == 1 && isempty(OPTIONS.TEMP_START)
+            if Y(1) > Y(end)
                 SUCCESSFUL_MOVES = SUCCESSFUL_MOVES+1;
-            elseif Y(1) <= Y(end),
+            elseif Y(1) <= Y(end)
                 UNSUCCESSFUL_MOVES = UNSUCCESSFUL_MOVES+1;
                 UNSUCCESSFUL_COSTS = UNSUCCESSFUL_COSTS+(Y(end)-Y(1));
             end
@@ -424,8 +424,8 @@ while 1,
     end
 
     % stop if previous for loop was broken due to some stop criterion
-    if ITERTEMP < MAXITERTEMP,
-        break;
+    if ITERTEMP < MAXITERTEMP
+        break
     end
     
     % store cost function values in COSTS vector
@@ -435,9 +435,9 @@ while 1,
     % using cooling schedule as proposed by Cardoso et al. (1996)
     % -----------------------------------------------------------
     
-    if TEMP_LOOP_NUMBER == 1 && isempty(OPTIONS.TEMP_START),
+    if TEMP_LOOP_NUMBER == 1 && isempty(OPTIONS.TEMP_START)
         TEMP = -(UNSUCCESSFUL_COSTS/(SUCCESSFUL_MOVES+UNSUCCESSFUL_MOVES))/log(((SUCCESSFUL_MOVES+UNSUCCESSFUL_MOVES)*OPTIONS.INITIAL_ACCEPTANCE_RATIO-SUCCESSFUL_MOVES)/UNSUCCESSFUL_MOVES);
-    elseif TEMP_LOOP_NUMBER ~= 0,
+    elseif TEMP_LOOP_NUMBER ~= 0
         STDEV_Y = std(COSTS);
         COOLING_FACTOR = 1/(1+TEMP*log(1+OPTIONS.COOL_RATE)/(3*STDEV_Y));
         TEMP = TEMP*min(OPTIONS.MIN_COOLING_FACTOR,COOLING_FACTOR);
@@ -502,14 +502,14 @@ function [YTRY] = CALCULATE_COST(FUN,PTRY,LB,UB,varargin)
 
 global YBEST PBEST NDIM nFUN_EVALS
 
-for i = 1:NDIM,
+for i = 1:NDIM
     % check lower bounds
-    if PTRY(i) < LB(i),
+    if PTRY(i) < LB(i)
         YTRY = 1e12+(LB(i)-PTRY(i))*1e6;
         return
     end
     % check upper bounds
-    if PTRY(i) > UB(i),
+    if PTRY(i) > UB(i)
         YTRY = 1e12+(PTRY(i)-UB(i))*1e6;
         return
     end
@@ -522,7 +522,7 @@ YTRY = feval(FUN,PTRY(:),varargin{:});
 nFUN_EVALS = nFUN_EVALS + 1;
 
 % save the best point ever
-if YTRY < YBEST,
+if YTRY < YBEST
     YBEST = YTRY;
     PBEST = PTRY;
 end
diff --git a/matlab/optimization/simpsaget.m b/matlab/optimization/simpsaget.m
index e482a3e00..e1c775495 100644
--- a/matlab/optimization/simpsaget.m
+++ b/matlab/optimization/simpsaget.m
@@ -56,7 +56,7 @@ end
 
 if isempty(options)
   o = default;
-  return;
+  return
 end
 
 Names = [
diff --git a/matlab/optimization/simpsaset.m b/matlab/optimization/simpsaset.m
index ca687891a..dc0aade4f 100644
--- a/matlab/optimization/simpsaset.m
+++ b/matlab/optimization/simpsaset.m
@@ -64,7 +64,7 @@ if (nargin == 0) && (nargout == 0)
     fprintf('                      DISPLAY: [ ''iter'' or ''none'' {''iter''} ]\n');
     fprintf('                   OUTPUT_FCN: [ function_handle ]\n');
     fprintf('\n');
-return;
+return
 end
 
 Names = [
@@ -97,7 +97,7 @@ i = 1;
 while i <= nargin
   arg = varargin{i};
   if ischar(arg)                         % arg is an option name
-    break;
+    break
   end
   if ~isempty(arg)                      % [] is a valid options argument
     if ~isa(arg,'struct')
diff --git a/matlab/optimization/simulated_annealing.m b/matlab/optimization/simulated_annealing.m
index 5b505b71d..35f0240e0 100644
--- a/matlab/optimization/simulated_annealing.m
+++ b/matlab/optimization/simulated_annealing.m
@@ -194,17 +194,17 @@ xopt=x;
 nacp=zeros(n,1);
 fstar=1e20*ones(optim.neps,1);
 %* If the initial temperature is not positive, notify the user and abort. *
-if(t<=0.0);
+if(t<=0.0)
     fprintf('\nThe initial temperature is not positive. Reset the variable t\n');
     exitflag=3;
-    return;
-end;
+    return
+end
 %*  If the initial value is out of bounds, notify the user and abort. *
-if(sum(x>ub)+sum(x<lb)>0);
+if(sum(x>ub)+sum(x<lb)>0)
     fprintf('\nInitial condition out of bounds\n');
     exitflag=2;
-    return;
-end;
+    return
+end
 %*  Evaluate the function with input x and return value as f. *
 f=feval(fcn,x,varargin{:});
 %*
@@ -212,98 +212,98 @@ f=feval(fcn,x,varargin{:});
 %  Note that all intermediate and final output switches the sign back
 %  to eliminate any possible confusion for the user.
 %*
-if(optim.maximizer_indicator==0);
+if(optim.maximizer_indicator==0)
     f=-f;
-end;
+end
 n_total_draws=n_total_draws+1;
 fopt=f;
 fstar(1)=f;
-if(optim.verbosity >1);
+if(optim.verbosity >1)
     disp '  ';
     disp(['initial x    ' num2str(x(:)')]);
-    if(optim.maximizer_indicator);
+    if(optim.maximizer_indicator)
         disp(['initial f    ' num2str(f)]);
     else
         disp(['initial f    ' num2str(-f)]);
-    end;
-end;
+    end
+end
 %  Start the main loop. Note that it terminates if (i) the algorithm
 %  succesfully optimizes the function or (ii) there are too many
 %  function evaluations (more than optim.MaxIter).
 
-while (1>0);
+while (1>0)
     nup=0;
     nrej=0;
     nnew=0;
     ndown=0;
     lnobds=0;
     m=1;
-    while m<=optim.nt;
+    while m<=optim.nt
         j=1;
-        while j<=optim.ns;
+        while j<=optim.ns
             h=1;
-            while h<=n;
+            while h<=n
                 %*  Generate xp, the trial value of x. Note use of vm to choose xp. *
                 i=1;
-                while i<=n;
-                    if(i==h);
+                while i<=n
+                    if(i==h)
                         xp(i)=x(i)+(rand(1,1)*2.0-1.0)*vm(i);
                     else
                         xp(i)=x(i);
-                    end;
+                    end
                     %*  If xp is out of bounds, select a point in bounds for the trial. *
-                    if((xp(i)<lb(i) || xp(i)>ub(i)));
+                    if((xp(i)<lb(i) || xp(i)>ub(i)))
                         xp(i)=lb(i)+(ub(i)-lb(i))*rand(1,1);
                         lnobds=lnobds+1;
                         n_out_of_bounds_draws=n_out_of_bounds_draws+1;
-                        if(optim.verbosity >=3);
+                        if(optim.verbosity >=3)
                             if exist('fp','var')
                                 print_current_invalid_try(optim.maximizer_indicator,xp,x,fp,f);
                             end
-                        end;
-                    end;
+                        end
+                    end
                     i=i+1;
-                end;
+                end
                 %*  Evaluate the function with the trial point xp and return as fp. *
                 % fp=feval(fcn,xp,listarg);
                 fp=feval(fcn,xp,varargin{:});
-                if(optim.maximizer_indicator==0);
+                if(optim.maximizer_indicator==0)
                     fp=-fp;
-                end;
+                end
                 n_total_draws=n_total_draws+1;
-                if(optim.verbosity >=3);
+                if(optim.verbosity >=3)
                     print_current_valid_try(optim.maximizer_indicator,xp,x,fp,f);
-                end;
+                end
                 %*  If too many function evaluations occur, terminate the algorithm. *
-                if(n_total_draws>=optim.MaxIter);
+                if(n_total_draws>=optim.MaxIter)
                     fprintf('Too many function evaluations; consider\n');
                     fprintf('increasing optim.MaxIter or optim.TolFun or decreasing\n');
                     fprintf('optim.nt or optim.rt. These results are likely to be poor\n');
-                    if(optim.maximizer_indicator==0);
+                    if(optim.maximizer_indicator==0)
                         fopt=-fopt;
-                    end;
+                    end
                     exitflag=1;
-                    return;
-                end;
+                    return
+                end
                 %*  Accept the new point if the function value increases. *
-                if(fp>=f);
-                    if(optim.verbosity >=3);
+                if(fp>=f)
+                    if(optim.verbosity >=3)
                         fprintf('point accepted\n');
-                    end;
+                    end
                     x=xp;
                     f=fp;
                     n_accepted_draws=n_accepted_draws+1;
                     nacp(h)=nacp(h)+1;
                     nup=nup+1;
                     %*  If greater than any other point, record as new optimum. *
-                    if(fp>fopt);
-                        if(optim.verbosity >=3);
+                    if(fp>fopt)
+                        if(optim.verbosity >=3)
                             fprintf('new optimum\n');
-                        end;
+                        end
                         xopt=xp;
                         fopt=fp;
                         nnew=nnew+1;
-                    end;
+                    end
                     %*
                     % If the point is lower, use the Metropolis criteria to decide on
                     % acceptance or rejection.
@@ -311,14 +311,14 @@ while (1>0);
                 else
                     p=exp((fp-f)/t);
                     pp=rand(1,1);
-                    if(pp<p);
-                        if(optim.verbosity >=3);
-                            if(optim.maximizer_indicator);
+                    if(pp<p)
+                        if(optim.verbosity >=3)
+                            if(optim.maximizer_indicator)
                              fprintf('though lower, point accepted\n');
                             else
                              fprintf('though higher, point accepted\n');
-                            end;
-                        end;
+                            end
+                        end
                         x=xp;
                         f=fp;
                         n_accepted_draws=n_accepted_draws+1;
@@ -326,87 +326,87 @@ while (1>0);
                         ndown=ndown+1;
                     else
                         nrej=nrej+1;
-                        if(optim.verbosity >=3);
-                            if(optim.maximizer_indicator);
+                        if(optim.verbosity >=3)
+                            if(optim.maximizer_indicator)
                                 fprintf('lower point rejected\n');
                             else
                                 fprintf('higher point rejected\n');
-                            end;
-                        end;
-                    end;
-                end;
+                            end
+                        end
+                    end
+                end
                 h=h+1;
-            end;
+            end
             j=j+1;
-        end;
+        end
         %*  Adjust vm so that approximately half of all evaluations are accepted. *
         i=1;
-        while i<=n;
+        while i<=n
             ratio=nacp(i)/optim.ns;
-            if(ratio>.6);
+            if(ratio>.6)
                 vm(i)=vm(i)*(1.+c(i)*(ratio-.6)/.4);
-            elseif(ratio<.4);
+            elseif(ratio<.4)
                 vm(i)=vm(i)/(1.+c(i)*((.4-ratio)/.4));
-            end;
-            if(vm(i)>(ub(i)-lb(i)));
+            end
+            if(vm(i)>(ub(i)-lb(i)))
                 vm(i)=ub(i)-lb(i);
-            end;
+            end
             i=i+1;
-        end;
-        if(optim.verbosity >=2);
+        end
+        if(optim.verbosity >=2)
             fprintf('intermediate results after step length adjustment\n');
             fprintf('new step length(vm)  %4.3f', vm(:)');
             fprintf('current optimal x    %4.3f', xopt(:)');
             fprintf('current x            %4.3f', x(:)');
-        end;
+        end
         nacp=zeros(n,1);
         m=m+1;
-    end;
-    if(optim.verbosity >=1);
+    end
+    if(optim.verbosity >=1)
         print_intermediate_statistics(optim.maximizer_indicator,t,xopt,vm,fopt,nup,ndown,nrej,lnobds,nnew);
-    end;
+    end
     %*  Check termination criteria. *
     quit=0;
     fstar(1)=f;
-    if((fopt-fstar(1))<=optim.TolFun);
+    if((fopt-fstar(1))<=optim.TolFun)
         quit=1;
-    end;
-    if(sum(abs(f-fstar)>optim.TolFun)>0);
+    end
+    if(sum(abs(f-fstar)>optim.TolFun)>0)
         quit=0;
-    end;
+    end
     %*  Terminate SA if appropriate. *
-    if(quit);
+    if(quit)
         exitflag=0;
-        if(optim.maximizer_indicator==0);
+        if(optim.maximizer_indicator==0)
             fopt=-fopt;
-        end;
-        if(optim.verbosity >=1);
+        end
+        if(optim.verbosity >=1)
             fprintf('SA achieved termination criteria.exitflag=0\n');
-        end;
-        return;        
-    end;
+        end
+        return        
+    end
     %*  If termination criteria are not met, prepare for another loop. *
     t=optim.rt*t;
     i=optim.neps;
-    while i>=2;
+    while i>=2
         fstar(i)=fstar(i-1);
         i=i-1;
-    end;
+    end
     f=fopt;
     x=xopt;
     %*  Loop again. *
-end;
+end
 
 end
 
 function  print_current_invalid_try(max,xp,x,fp,f)
 fprintf('\n');
     disp(['Current x    ' num2str(x(:)')]);
-if(max);
+if(max)
     disp(['Current f    ' num2str(f)]);
 else
     disp(['Current f    ' num2str(-f)]);
-end;
+end
 disp(['Trial x      ' num2str(xp(:)')]);
 disp 'Point rejected since out of bounds';
 end
@@ -414,7 +414,7 @@ end
 function print_current_valid_try(max,xp,x,fp,f)
 
 disp(['Current x    ' num2str(x(:)')]);
-if(max);
+if(max)
     disp(['Current f   ' num2str(f)]);
     disp(['Trial x     ' num2str(xp(:)')]);
     disp(['Resulting f ' num2str(fp)]);
@@ -422,7 +422,7 @@ else
     disp(['Current f   ' num2str(-f)]);
     disp(['Trial x     ' num2str(xp(:)')]);
     disp(['Resulting f ' num2str(-fp)]);
-end;
+end
 end
 
 
diff --git a/matlab/optimization/solvopt.m b/matlab/optimization/solvopt.m
index 6d5693e86..9976ad850 100644
--- a/matlab/optimization/solvopt.m
+++ b/matlab/optimization/solvopt.m
@@ -162,7 +162,7 @@ if isempty(func)
     constr=0;
 else
     constr=1;                  % Constrained problem
-    if isempty(gradc),
+    if isempty(gradc)
         appconstr=1;
     else
         appconstr=0;            % Exact gradients of constraints are supplied
@@ -201,7 +201,7 @@ end
 epsnorm=1.e-15;
 epsnorm2=1.e-30;    % epsilon & epsilon^2
 
-if constr, h1=-1;                  % NLP: restricted to minimization
+if constr, h1=-1                  % NLP: restricted to minimization
     cnteps=optim.TolXConstraint;                % Max. admissible residual
 else
     h1=sign(optim.minimizer_indicator);         % Minimize resp. maximize a function
@@ -220,7 +220,7 @@ knorms=0; gnorms=zeros(1,10);    % Gradient norms stored
 %---}
 
 %Display control ---{
-if optim.verbosity<=0, dispdata=0;
+if optim.verbosity<=0, dispdata=0
     if optim.verbosity==-1
         dispwarn=0;
     else
@@ -276,30 +276,79 @@ else
     f=feval(fun,x,varargin{:});
 end
 n_f_evals=n_f_evals+1;
-if isempty(f),      if dispwarn,disp(errmes);disp(error30);end
-    exitflag=-3; if trx, x=x';end, return
-elseif isnan(f),    if dispwarn,disp(errmes);disp(error31);disp(error6);end
-    exitflag=-3; if trx, x=x';end, return
-elseif abs(f)==Inf, if dispwarn,disp(errmes);disp(error32);disp(error6);end
-    exitflag=-3; if trx, x=x';end, return
+if isempty(f)
+    if dispwarn
+        disp(errmes)
+        disp(error30)
+    end
+    exitflag=-3;
+    if trx 
+        x=x';
+    end
+    return
+elseif isnan(f)
+    if dispwarn
+        disp(errmes)
+        disp(error31)
+        disp(error6)
+    end
+    exitflag=-3;
+    if trx
+        x=x';
+    end
+    return
+elseif abs(f)==Inf
+    if dispwarn
+        disp(errmes)
+        disp(error32)
+        disp(error6)
+    end
+    exitflag=-3;
+    if trx
+        x=x';
+    end
+    return
 end
 xrec=x; frec=f;     % record point and function value
 % Constrained problem
-if constr,  fp=f; kless=0;
-    if trx,
+if constr,  fp=f; kless=0
+    if trx
         fc=feval(func,x');
     else
         fc=feval(func,x);
     end
-    if isempty(fc),
-        if dispwarn,disp(errmes);disp(error50);end
-        exitflag=-5; if trx, x=x';end, return
-    elseif isnan(fc),
-        if dispwarn,disp(errmes);disp(error51);disp(error6);end
-        exitflag=-5; if trx, x=x';end, return
-    elseif abs(fc)==Inf,
-        if dispwarn,disp(errmes);disp(error52);disp(error6);end
-        exitflag=-5; if trx, x=x';end, return
+    if isempty(fc)
+        if dispwarn
+            disp(errmes)
+            disp(error50)
+        end
+        exitflag=-5;
+        if trx
+            x=x';
+        end
+        return
+    elseif isnan(fc)
+        if dispwarn
+            disp(errmes)
+            disp(error51)
+            disp(error6)
+        end
+        exitflag=-5;
+        if trx
+            x=x';
+        end
+        return
+    elseif abs(fc)==Inf
+        if dispwarn
+            disp(errmes)
+            disp(error52)
+            disp(error6)
+        end
+        exitflag=-5;
+        if trx
+            x=x';
+        end
+        return
     end
     n_constraint_evals=n_constraint_evals+1;
     PenCoef=1;                              % first rough approximation
@@ -336,19 +385,55 @@ else
     end
     n_grad_evals=n_grad_evals+1;
 end
-if size(g,2)==1, g=g'; end, ng=norm(g);
-if size(g,2)~=n,    if dispwarn,disp(errmes);disp(error40);end
-    exitflag=-4; if trx, x=x';end, return
-elseif isnan(ng),   if dispwarn,disp(errmes);disp(error41);disp(error6);end
-    exitflag=-4; if trx, x=x';end, return
-elseif ng==Inf,     if dispwarn,disp(errmes);disp(error42);disp(error6);end
-    exitflag=-4; if trx, x=x';end, return
-elseif ng<ZeroGrad, if dispwarn,disp(errmes);disp(error43);disp(error6);end
-    exitflag=-4; if trx, x=x';end, return
+if size(g,2)==1, g=g'; end
+ng=norm(g);
+if size(g,2)~=n
+    if dispwarn
+        disp(errmes)
+        disp(error40)
+    end
+    exitflag=-4;
+    if trx
+        x=x';
+    end 
+    return
+elseif isnan(ng)
+    if dispwarn
+        disp(errmes)
+        disp(error41)
+        disp(error6)
+    end
+    exitflag=-4;
+    if trx
+        x=x';
+    end
+    return
+elseif ng==Inf
+    if dispwarn
+        disp(errmes)
+        disp(error42)
+        disp(error6)
+    end
+    exitflag=-4;
+    if trx
+        x=x';
+    end
+    return
+elseif ng<ZeroGrad
+    if dispwarn
+        disp(errmes)
+        disp(error43)
+        disp(error6)
+    end
+    exitflag=-4;
+    if trx
+        x=x';
+    end
+    return
 end
 if constr
     if ~FP
-        if appconstr,
+        if appconstr
             deltax=sign(x); idx=find(deltax==0);
             deltax(idx)=ones(size(idx));  
             deltax=ddx*deltax;
@@ -370,42 +455,42 @@ if constr
             gc=gc'; 
         end
         ngc=norm(gc);
-        if size(gc,2)~=n,
+        if size(gc,2)~=n
             if dispwarn
-                disp(errmes);
-                disp(error60);
+                disp(errmes)
+                disp(error60)
             end
             exitflag=-6; 
             if trx
                 x=x';
             end
             return
-        elseif isnan(ngc),
+        elseif isnan(ngc)
             if dispwarn
-                disp(errmes);
-                disp(error61);
-                disp(error6);
+                disp(errmes)
+                disp(error61)
+                disp(error6)
             end
-            exitflag=-6; 
+            exitflag=-6;
             if trx
                 x=x';
             end
             return
-        elseif ngc==Inf,
+        elseif ngc==Inf
             if dispwarn
-                disp(errmes);
-                disp(error62);
-                disp(error6);
+                disp(errmes)
+                disp(error62)
+                disp(error6)
             end
             exitflag=-6; 
             if trx
                 x=x';
             end
             return
-        elseif ngc<ZeroGrad,
+        elseif ngc<ZeroGrad
             if dispwarn
-                disp(errmes);
-                disp(error63);
+                disp(errmes)
+                disp(error63)
             end
             exitflag=-6; 
             if trx
@@ -414,19 +499,20 @@ if constr
             return
         end
         g=g+PenCoef*gc; ng=norm(g);
-    end, end
+    end
+end
 grec=g; nng=ng;
 % ----}
 % INITIAL STEPSIZE
 h=h1*sqrt(optim.TolX)*max(abs(x));     % smallest possible stepsize
-if abs(optim.minimizer_indicator)~=1,
+if abs(optim.minimizer_indicator)~=1
     h=h1*max(abs([optim.minimizer_indicator,h]));     % user-supplied stepsize
 else
     h=h1*max(1/log(ng+1.1),abs(h));    % calculated stepsize
 end
 
 % RESETTING LOOP ----{
-while 1,
+while 1
     kcheck=0;                        % Set checkpoint counter.
     kg=0;                            % stepsizes stored
     kj=0;                            % ravine jump counter
@@ -436,7 +522,7 @@ while 1,
     
     % MAIN ITERATIONS ----{
     
-    while 1,
+    while 1
         k=k+1;kcheck=kcheck+1;
         laststep=dx;
         
@@ -447,11 +533,21 @@ while 1,
         gt=g*B;   w=wdef;
         % JUMPING OVER A RAVINE ----{
         if (gt/norm(gt))*(g1'/norm(g1))<low_bound
-            if kj==2, xx=x;  end,  if kj==0, kd=4;  end,
+            if kj==2
+                xx=x;    
+            end 
+            if kj==0
+                kd=4
+            end
             kj=kj+1;  w=-.9; h=h*2;             % use large coef. of space dilation
-            if kj>2*kd,     kd=kd+1;  warnno=1;
-                if any(abs(x-xx)<epsnorm*abs(x)), % flat bottom is detected
-                    if dispwarn,disp(wrnmes);disp(warn08); end
+            if kj>2*kd
+                kd=kd+1;
+                warnno=1;
+                if any(abs(x-xx)<epsnorm*abs(x)) % flat bottom is detected
+                    if dispwarn
+                        disp(wrnmes)
+                        disp(warn08)
+                    end
                 end
             end
         else
@@ -474,9 +570,12 @@ while 1,
         % RESETTING ----{
         if kcheck>1
             idx=find(abs(g)>ZeroGrad); numelem=size(idx,2);
-            if numelem>0, grbnd=epsnorm*numelem^2;
-                if all(abs(g1(idx))<=abs(g(idx))*grbnd) | nrmz==0
-                    if dispwarn,  disp(wrnmes);  disp(warn20); end
+            if numelem>0, grbnd=epsnorm*numelem^2
+                if all(abs(g1(idx))<=abs(g(idx))*grbnd) || nrmz==0
+                    if dispwarn
+                        disp(wrnmes)
+                        disp(warn20)
+                    end
                     if abs(fst-f)<abs(f)*.01
                         ajp=ajp-10*n;
                     else
@@ -493,9 +592,12 @@ while 1,
         xopt=x;fopt=f;   k1=0;k2=0;ksm=0;kc=0;knan=0;  hp=h;
         if constr, Reset=0; end
         % 1-D SEARCH ----{
-        while 1,
+        while 1
             x1=x;f1=f;
-            if constr, FP1=FP; fp1=fp; end
+            if constr
+                FP1=FP;
+                fp1=fp;
+            end
             x=x+hp*g0;
             % FUNCTION VALUE
             if trx
@@ -506,8 +608,8 @@ while 1,
             n_f_evals=n_f_evals+1;
             if h1*f==Inf
                 if dispwarn
-                    disp(errmes); 
-                    disp(error5); 
+                    disp(errmes)
+                    disp(error5) 
                 end
                 exitflag=-7; 
                 if trx
@@ -522,12 +624,28 @@ while 1,
                     fc=feval(func,x);
                 end
                 n_constraint_evals=n_constraint_evals+1;
-                if  isnan(fc),
-                    if dispwarn,disp(errmes);disp(error51);disp(error6);end
-                    exitflag=-5; if trx, x=x';end, return
-                elseif abs(fc)==Inf,
-                    if dispwarn,disp(errmes);disp(error52);disp(error6);end
-                    exitflag=-5; if trx, x=x';end, return
+                if  isnan(fc)
+                    if dispwarn
+                        disp(errmes)
+                        disp(error51)
+                        disp(error6)
+                    end
+                    exitflag=-5;
+                    if trx
+                        x=x';
+                    end
+                    return
+                elseif abs(fc)==Inf
+                    if dispwarn
+                        disp(errmes)
+                        disp(error52)
+                        disp(error6)
+                    end
+                    exitflag=-5;
+                    if trx
+                        x=x';
+                    end
+                    return
                 end
                 if fc<=cnteps
                     FP=1; 
@@ -538,7 +656,7 @@ while 1,
                     if fp_rate<-epsnorm
                         if ~FP1
                             PenCoefNew=-15*fp_rate/norm(x-x1);
-                            if PenCoefNew>1.2*PenCoef,
+                            if PenCoefNew>1.2*PenCoef
                                 PenCoef=PenCoefNew; Reset=1; kless=0; f=f+PenCoef*fc; break
                             end
                         end
@@ -547,22 +665,22 @@ while 1,
                 f=f+PenCoef*fc;
             end
             if abs(f)==Inf || isnan(f)
-                if dispwarn, disp(wrnmes);
+                if dispwarn, disp(wrnmes)
                     if isnan(f)
-                        disp(error31); 
+                        disp(error31)
                     else
-                        disp(error32); 
+                        disp(error32) 
                     end
                 end
                 if ksm || kc>=mxtc
-                    exitflag=-3; 
+                    exitflag=-3;
                     if trx
                         x=x';
                     end
                     return
                 else
                     k2=k2+1;
-                    k1=0; 
+                    k1=0;
                     hp=hp/dq; 
                     x=x1;
                     f=f1; 
@@ -573,13 +691,18 @@ while 1,
                     end
                 end
                 % STEP SIZE IS ZERO TO THE EXTENT OF EPSNORM
-            elseif all(abs(x-x1)<abs(x)*epsnorm),
+            elseif all(abs(x-x1)<abs(x)*epsnorm)
                 stepvanish=stepvanish+1;
-                if stepvanish>=5,
+                if stepvanish>=5
                     exitflag=-14;
-                    if dispwarn, disp(termwarn1);
-                        disp(endwarn(4,:)); end
-                    if trx,x=x';end,  return
+                    if dispwarn
+                        disp(termwarn1)
+                        disp(endwarn(4,:))
+                    end
+                    if trx
+                        x=x';
+                    end
+                    return
                 else
                     x=x1; 
                     f=f1; 
@@ -592,24 +715,44 @@ while 1,
                 end
                 % USE SMALLER STEP
             elseif h1*f<h1*gamma^sign(f1)*f1
-                if ksm,break,end,  k2=k2+1;k1=0; hp=hp/dq; x=x1;f=f1;
-                if constr, FP=FP1; fp=fp1; end
+                if ksm
+                    break
+                end 
+                k2=k2+1;k1=0; hp=hp/dq; x=x1;f=f1;
+                if constr
+                    FP=FP1;
+                    fp=fp1;
+                end
                 if kc>=mxtc, break, end
                 % 1-D OPTIMIZER IS LEFT BEHIND
-            else   if h1*f<=h1*f1, break,  end
+            else 
+                if h1*f<=h1*f1
+                    break
+                end
                 % USE LARGER STEP
-                k1=k1+1; if k2>0, kc=kc+1; end, k2=0;
-                if k1>=20,      hp=du20*hp;
-                elseif k1>=10,  hp=du10*hp;
-                elseif k1>=3,   hp=du03*hp;
+                k1=k1+1; 
+                if k2>0
+                    kc=kc+1;
+                end
+                k2=0;
+                if k1>=20
+                    hp=du20*hp;
+                elseif k1>=10
+                    hp=du10*hp;
+                elseif k1>=3
+                    hp=du03*hp;
                 end
             end
         end
         % ----}  End of 1-D search
         % ADJUST THE TRIAL STEP SIZE ----{
         dx=norm(xopt-x);
-        if kg<kstore,  kg=kg+1;  end
-        if kg>=2,  nsteps(2:kg)=nsteps(1:kg-1); end
+        if kg<kstore
+            kg=kg+1;
+        end
+        if kg>=2
+            nsteps(2:kg)=nsteps(1:kg-1);
+        end
         nsteps(1)=dx/(abs(h)*norm(g0));
         kk=sum(nsteps(1:kg).*[kg:-1:1])/sum([kg:-1:1]);
         if     kk>des
@@ -625,7 +768,7 @@ while 1,
         stepvanish=stepvanish+ksm;
         % ----}
         % COMPUTE THE GRADIENT ----{
-        if app,
+        if app
             deltax=sign(g0); idx=find(deltax==0);
             deltax(idx)=ones(size(idx));  deltax=h1*ddx*deltax;
             if constr
@@ -650,15 +793,35 @@ while 1,
             end
             n_grad_evals=n_grad_evals+1;
         end
-        if size(g,2)==1, g=g'; end,    ng=norm(g);
-        if isnan(ng),
-            if dispwarn, disp(errmes); disp(error41); end
-            exitflag=-4; if trx, x=x'; end, return
-        elseif ng==Inf,
-            if dispwarn,disp(errmes);disp(error42);end
-            exitflag=-4; if trx, x=x';end, return
-        elseif ng<ZeroGrad,
-            if dispwarn,disp(wrnmes);disp(warn1);end
+        if size(g,2)==1
+            g=g'
+        end
+        ng=norm(g);
+        if isnan(ng)
+            if dispwarn
+                disp(errmes)
+                disp(error41)
+            end
+            exitflag=-4;
+            if trx
+                x=x';
+            end
+            return
+        elseif ng==Inf
+            if dispwarn
+                disp(errmes)
+                disp(error42)
+            end
+            exitflag=-4;
+            if trx
+                x=x';
+            end
+            return
+        elseif ng<ZeroGrad
+            if dispwarn
+                disp(wrnmes)
+                disp(warn1)
+            end
             ng=ZeroGrad;
         end
         % Constraints:
@@ -666,11 +829,15 @@ while 1,
             if ~FP
                 if ng<.01*PenCoef
                     kless=kless+1;
-                    if kless>=20, PenCoef=PenCoef/10; Reset=1; kless=0; end
+                    if kless>=20
+                        PenCoef=PenCoef/10;
+                        Reset=1;
+                        kless=0;
+                    end
                 else
                     kless=0;
                 end
-                if appconstr,
+                if appconstr
                     deltax=sign(x); idx=find(deltax==0);
                     deltax(idx)=ones(size(idx));  deltax=ddx*deltax;
                     if trx
@@ -687,27 +854,64 @@ while 1,
                     end
                     n_constraint_gradient_evals=n_constraint_gradient_evals+1;
                 end
-                if size(gc,2)==1, gc=gc'; end, ngc=norm(gc);
-                if     isnan(ngc),
-                    if dispwarn,disp(errmes);disp(error61);end
-                    exitflag=-6; if trx, x=x';end, return
-                elseif ngc==Inf,
-                    if dispwarn,disp(errmes);disp(error62);end
-                    exitflag=-6; if trx, x=x';end, return
-                elseif ngc<ZeroGrad && ~appconstr,
-                    if dispwarn,disp(errmes);disp(error63);end
-                    exitflag=-6; if trx, x=x';end, return
+                if size(gc,2)==1
+                    gc=gc';
+                end
+                ngc=norm(gc);
+                if isnan(ngc)
+                    if dispwarn
+                        disp(errmes)
+                        disp(error61)
+                    end
+                    exitflag=-6;
+                    if trx
+                        x=x';
+                    end
+                    return
+                elseif ngc==Inf
+                    if dispwarn
+                        disp(errmes)
+                        disp(error62)
+                    end
+                    exitflag=-6;
+                    if trx
+                        x=x';
+                    end
+                    return
+                elseif ngc<ZeroGrad && ~appconstr
+                    if dispwarn
+                        disp(errmes)
+                        disp(error63)
+                    end
+                    exitflag=-6;
+                    if trx
+                        x=x';
+                    end
+                    return
                 end
                 g=g+PenCoef*gc; ng=norm(g);
-                if Reset, if dispwarn,  disp(wrnmes);  disp(warn21); end
+                if Reset
+                    if dispwarn 
+                        disp(wrnmes)
+                        disp(warn21)
+                    end
                     h=h1*dx/3; k=k-1; nng=ng; break
                 end
-            end, end
-        if h1*f>h1*frec, frec=f; xrec=x; grec=g; end
+            end
+        end
+        if h1*f>h1*frec
+            frec=f;
+            xrec=x;
+            grec=g;
+        end
         % ----}
-        if ng>ZeroGrad,
-            if knorms<10,  knorms=knorms+1;  end
-            if knorms>=2,  gnorms(2:knorms)=gnorms(1:knorms-1); end
+        if ng>ZeroGrad
+            if knorms<10
+                knorms=knorms+1;
+            end
+            if knorms>=2
+                gnorms(2:knorms)=gnorms(1:knorms-1);
+            end
             gnorms(1)=ng;
             nng=(prod(gnorms(1:knorms)))^(1/knorms);
         end
@@ -721,10 +925,20 @@ while 1,
         %----}
         % CHECK THE STOPPING CRITERIA ----{
         termflag=1;
-        if constr, if ~FP, termflag=0; end, end
-        if kcheck<=5, termflag=0; end
-        if knan, termflag=0; end
-        if kc>=mxtc, termflag=0; end
+        if constr
+            if ~FP
+                termflag=0;
+            end
+        end
+        if kcheck<=5
+            termflag=0;
+        end
+        if knan
+            termflag=0
+        end
+        if kc>=mxtc
+            termflag=0;
+        end
         % ARGUMENT
         if termflag
             idx=find(abs(x)>=lowxbound);
@@ -737,8 +951,8 @@ while 1,
                         ~constr
                     if any(abs(xrec(idx)-x(idx))> detxr * abs(x(idx)))
                         if dispwarn
-                            disp(wrnmes);
-                            disp(warn09);
+                            disp(wrnmes)
+                            disp(warn09)
                         end
                         x=xrec; 
                         f=frec; 
@@ -759,13 +973,21 @@ while 1,
                         (abs(f-fopt)<=optim.TolFun && termx>=limxterm )
                     if stopf
                         if dx<=laststep
-                            if warnno==1 && ng<sqrt(optim.TolFun), warnno=0; end
-                            if ~app, if any(abs(g)<=epsnorm2), warnno=3; end, end
+                            if warnno==1 && ng<sqrt(optim.TolFun)
+                                warnno=0;
+                            end
+                            if ~app
+                                if any(abs(g)<=epsnorm2)
+                                    warnno=3;
+                                end
+                            end
                             if warnno~=0
                                 exitflag=-warnno-10;
-                                if dispwarn, disp(termwarn1);
-                                    disp(endwarn(warnno,:));
-                                    if app, disp(appwarn); end
+                                if dispwarn, disp(termwarn1)
+                                    disp(endwarn(warnno,:))
+                                    if app
+                                        disp(appwarn);
+                                    end
                                 end
                             else
                                 exitflag=k;
@@ -783,11 +1005,18 @@ while 1,
                     end
                 elseif dx<1.e-12*max(norm(x),1) && termx>=limxterm
                     exitflag=-14;
-                    if dispwarn, disp(termwarn1); disp(endwarn(4,:));
-                        if app, disp(appwarn); end
+                    if dispwarn
+                        disp(termwarn1)
+                        disp(endwarn(4,:))
+                        if app
+                            disp(appwarn)
+                        end
                     end
                     x=xrec; f=frec;
-                    if trx,x=x';end,  return
+                    if trx
+                        x=x';
+                    end
+                    return
                 else
                     stopf=0;
                 end
@@ -798,15 +1027,21 @@ while 1,
             exitflag=-9; 
             if trx
                 x=x'; 
-            end,
-            if dispwarn, disp(wrnmes);  disp(warn4); end
+            end
+            if dispwarn
+                disp(wrnmes)
+                disp(warn4)
+            end
             return
         end
         % ----}
         % ZERO GRADIENT ----{
         if constr
-            if ng<=ZeroGrad,
-                if dispwarn,  disp(termwarn1);  disp(warn1); end
+            if ng<=ZeroGrad
+                if dispwarn
+                    disp(termwarn1)
+                    disp(warn1)
+                end
                 exitflag=-8; 
                 if trx
                     x=x';
@@ -814,8 +1049,12 @@ while 1,
                 return
             end
         else
-            if ng<=ZeroGrad,        nzero=nzero+1;
-                if dispwarn, disp(wrnmes);  disp(warn1);  end
+            if ng<=ZeroGrad
+                nzero=nzero+1;
+                if dispwarn
+                    disp(wrnmes)
+                    disp(warn1)
+                end
                 if nzero>=3
                     exitflag=-8; 
                     if trx
@@ -824,7 +1063,7 @@ while 1,
                     return
                 end
                 g0=-h*g0/2;
-                for i=1:10,
+                for i=1:10
                     x=x+g0;
                     if trx
                         f=feval(fun,x',varargin{:});
@@ -834,18 +1073,18 @@ while 1,
                     n_f_evals=n_f_evals+1;
                     if abs(f)==Inf
                         if dispwarn
-                            disp(errmes);  
-                            disp(error32);  
+                            disp(errmes)
+                            disp(error32)  
                         end
                         exitflag=-3;
                         if trx
                             x=x';
                         end
                         return
-                    elseif isnan(f),
+                    elseif isnan(f)
                         if dispwarn
-                            disp(errmes);  
-                            disp(error32);  
+                            disp(errmes)  
+                            disp(error32)  
                         end
                         exitflag=-3;
                         if trx
@@ -853,7 +1092,7 @@ while 1,
                         end
                         return
                     end
-                    if app,
+                    if app
                         deltax=sign(g0); 
                         idx=find(deltax==0);
                         deltax(idx)=ones(size(idx));  
@@ -878,8 +1117,8 @@ while 1,
                     ng=norm(g);
                     if ng==Inf
                         if dispwarn
-                            disp(errmes);  
-                            disp(error42); 
+                            disp(errmes)
+                            disp(error42) 
                         end
                         exitflag=-4; 
                         if trx
@@ -888,8 +1127,8 @@ while 1,
                         return
                     elseif isnan(ng)
                         if dispwarn
-                            disp(errmes);  
-                            disp(error41); 
+                            disp(errmes)  
+                            disp(error41) 
                         end
                         exitflag=-4; 
                         if trx
@@ -901,10 +1140,10 @@ while 1,
                         break
                     end
                 end
-                if ng<=ZeroGrad,
+                if ng<=ZeroGrad
                     if dispwarn
-                        disp(termwarn1);  
-                        disp(warn1); 
+                        disp(termwarn1) 
+                        disp(warn1)
                     end
                     exitflag=-8; 
                     if trx
@@ -921,19 +1160,32 @@ while 1,
         if ~constr && abs(f-fopt)<abs(fopt)*optim.TolFun && kcheck>5 && ng<1
             idx=find(abs(g)<=epsnorm2); 
             ni=size(idx,2);
-            if ni>=1 && ni<=n/2 && kflat<=3, kflat=kflat+1;
-                if dispwarn,  disp(wrnmes); disp(warn31); end, warnno=1;
+            if ni>=1 && ni<=n/2 && kflat<=3
+                kflat=kflat+1;
+                if dispwarn
+                    disp(wrnmes)
+                    disp(warn31)
+                end
+                warnno=1;
                 x1=x; fm=f;
-                for j=idx, y=x(j); f2=fm;
-                    if y==0, x1(j)=1; elseif abs(y)<1, x1(j)=sign(y); else, x1(j)=y; end
-                    for i=1:20, x1(j)=x1(j)/1.15;
+                for j=idx
+                    y=x(j); f2=fm;
+                    if y==0
+                        x1(j)=1;
+                    elseif abs(y)<1
+                        x1(j)=sign(y);
+                    else 
+                        x1(j)=y;
+                    end
+                    for i=1:20
+                        x1(j)=x1(j)/1.15;
                         if trx
                             f1=feval(fun,x1',varargin{:});
                         else
                             f1=feval(fun,x1,varargin{:}); 
                         end
                         n_f_evals=n_f_evals+1;
-                        if abs(f1)~=Inf && ~isnan(f1),
+                        if abs(f1)~=Inf && ~isnan(f1)
                             if h1*f1>h1*fm
                                 y=x1(j); 
                                 fm=f1;
@@ -948,7 +1200,7 @@ while 1,
                     x1(j)=y;
                 end
                 if h1*fm>h1*f
-                    if app,
+                    if app
                         deltax=h1*ddx*ones(size(deltax));
                         if trx
                             gt=apprgrdn(x1',fm,fun,deltax',1,varargin{:});
@@ -968,9 +1220,9 @@ while 1,
                         gt=gt'; 
                     end
                     ngt=norm(gt);
-                    if ~isnan(ngt) && ngt>epsnorm2,
+                    if ~isnan(ngt) && ngt>epsnorm2
                         if dispwarn
-                            disp(warn32); 
+                            disp(warn32)
                         end
                         optim.TolFun=optim.TolFun/5;
                         x=x1; 
diff --git a/matlab/optimize_prior.m b/matlab/optimize_prior.m
index cdb03ecff..ffa5ff3df 100644
--- a/matlab/optimize_prior.m
+++ b/matlab/optimize_prior.m
@@ -34,7 +34,7 @@ while look_for_admissible_initial_condition
             look_for_admissible_initial_condition = 0;
         end
     else
-        if iter == 2000;
+        if iter == 2000
             scale = scale/1.1;
             iter  = 0;
         else
diff --git a/matlab/parallel/AnalyseComputationalEnvironment.m b/matlab/parallel/AnalyseComputationalEnvironment.m
index e5d2a87f5..c214ec405 100644
--- a/matlab/parallel/AnalyseComputationalEnvironment.m
+++ b/matlab/parallel/AnalyseComputationalEnvironment.m
@@ -31,7 +31,7 @@ function [ErrorCode] = AnalyseComputationalEnvironment(DataInput, DataInputAdd)
 %   field RemoteTmpFolder (the temporary directory created/destroyed on remote
 %   computer) is used.
 
-if ispc, 
+if ispc
     [tempo, MasterName]=system('hostname');
     MasterName=deblank(MasterName);
 end
@@ -114,11 +114,11 @@ for Node=1:length(DataInput) % To obtain a recoursive function remove the 'for'
     OScallerUnix=~ispc;
     OScallerWindows=ispc;
     OStargetUnix=strcmpi('unix',DataInput(Node).OperatingSystem);
-    if isempty(DataInput(Node).OperatingSystem),
+    if isempty(DataInput(Node).OperatingSystem)
         OStargetUnix=OScallerUnix;
     end
     OStargetWindows=strcmpi('windows',DataInput(Node).OperatingSystem);
-    if isempty(DataInput(Node).OperatingSystem),
+    if isempty(DataInput(Node).OperatingSystem)
         OStargetWindows=OScallerWindows;
     end
     
@@ -279,7 +279,7 @@ for Node=1:length(DataInput) % To obtain a recoursive function remove the 'for'
             
             si2=[];
             de2=[];
-            if ~isempty(DataInput(Node).Port),
+            if ~isempty(DataInput(Node).Port)
                 ssh_token = ['-p ',DataInput(Node).Port];
             else
                 ssh_token = '';
@@ -347,11 +347,11 @@ for Node=1:length(DataInput) % To obtain a recoursive function remove the 'for'
         s2='fclose(fT);\n';
         SBS=strfind(DataInput(Node).DynarePath,'\');
         DPStr=DataInput(Node).DynarePath;
-        if isempty(SBS),
+        if isempty(SBS)
             DPStrNew=DPStr;
         else
             DPStrNew=[DPStr(1:SBS(1)),'\'];
-            for j=2:length(SBS),
+            for j=2:length(SBS)
                 DPStrNew=[DPStrNew,DPStr(SBS(j-1)+1:SBS(j)),'\'];
             end
             DPStrNew=[DPStrNew,DPStr(SBS(end)+1:end)];
@@ -401,8 +401,8 @@ for Node=1:length(DataInput) % To obtain a recoursive function remove the 'for'
         % machine when the user is .UserName with password .Password and
         % the path is MatlabOctavePath.
         
-        if Environment,
-            if ~isempty(DataInput(Node).Port),
+        if Environment
+            if ~isempty(DataInput(Node).Port)
                 ssh_token = ['-p ',DataInput(Node).Port];
             else
                 ssh_token = '';
@@ -413,7 +413,7 @@ for Node=1:length(DataInput) % To obtain a recoursive function remove the 'for'
                 system(['ssh ',ssh_token,' ',DataInput(Node).UserName,'@',DataInput(Node).ComputerName,' "cd ',DataInput(Node).RemoteDirectory,'/',RemoteTmpFolder,  '; ', DataInput(Node).MatlabOctavePath, ' -nosplash -nodesktop -minimize -r Tracing;" &']);
             end
         else
-            if ~strcmp(DataInput(Node).ComputerName,MasterName), % run on remote machine
+            if ~strcmp(DataInput(Node).ComputerName,MasterName) % run on remote machine
                 if  strfind([DataInput(Node).MatlabOctavePath], 'octave') % Hybrid computing Matlab(Master)->Octave(Slaves) and Vice Versa!
                     [NonServeS NenServeD]=system(['start /B psexec \\',DataInput(Node).ComputerName,' -e -u ',DataInput(Node).UserName,' -p ',DataInput(Node).Password,' -W ',DataInput(Node).RemoteDrive,':\',DataInput(Node).RemoteDirectory,'\',RemoteTmpFolder ' -low   ',DataInput(Node).MatlabOctavePath,' Tracing.m']);
                 else
@@ -433,14 +433,15 @@ for Node=1:length(DataInput) % To obtain a recoursive function remove the 'for'
         
         t1=fix(clock);
         
-        if t1(5)+1>60;
+        if t1(5)+1>60
             t2=2;
-        else t2=t1(5)+1;
+        else
+            t2=t1(5)+1;
         end
         
         Flag=0;
         
-        while (1);
+        while (1)
             if Flag==0
                 disp('Try to run matlab/octave on remote machine ... ')
                 skipline()
@@ -556,7 +557,7 @@ for Node=1:length(DataInput) % To obtain a recoursive function remove the 'for'
     Environment1=Environment;
     disp('Checking Hardware please wait ...');
     if (DataInput(Node).Local == 1)
-        if Environment,
+        if Environment
             if ~ismac
                 [si0 de0]=system('grep processor /proc/cpuinfo');
             else
@@ -567,14 +568,14 @@ for Node=1:length(DataInput) % To obtain a recoursive function remove the 'for'
             [si0 de0]=system(['psinfo \\']);
         end
     else
-        if Environment,
-            if ~isempty(DataInput(Node).Port),
+        if Environment
+            if ~isempty(DataInput(Node).Port)
                 ssh_token = ['-p ',DataInput(Node).Port];
             else
                 ssh_token = '';
             end
-            if OStargetUnix,
-                if RemoteEnvironment ==1 , 
+            if OStargetUnix
+                if RemoteEnvironment ==1
                     [si0 de0]=system(['ssh ',ssh_token,' ',DataInput(Node).UserName,'@',DataInput(Node).ComputerName,' grep processor /proc/cpuinfo']);
                 else % it is MAC
                     [si0 de0]=system(['ssh ',ssh_token,' ',DataInput(Node).UserName,'@',DataInput(Node).ComputerName,' sysctl -n hw.ncpu']);
@@ -594,7 +595,7 @@ for Node=1:length(DataInput) % To obtain a recoursive function remove the 'for'
     RealCPUnbr=GiveCPUnumber(de0,Environment1);
     
     % Questo controllo penso che si possa MIGLIORARE!!!!!
-    if  isempty (RealCPUnbr) && Environment1==0,
+    if  isempty (RealCPUnbr) && Environment1==0
         [si0 de0]=system(['psinfo \\',DataInput(Node).ComputerName]);
     end        
     RealCPUnbr=GiveCPUnumber(de0,Environment1);
@@ -626,7 +627,7 @@ for Node=1:length(DataInput) % To obtain a recoursive function remove the 'for'
     
     disp(['Hardware has ', num2str(RealCPUnbr),' Cpu/Cores!'])
     disp(['User requires ',num2str(CPUnbrUser),' Cpu/Cores!'])
-    if  CPUnbrUser==RealCPUnbr,
+    if  CPUnbrUser==RealCPUnbr
         % It is Ok!
         disp('Check on CPUnbr Variable ..... Ok!')
         skipline(3)
diff --git a/matlab/parallel/GiveCPUnumber.m b/matlab/parallel/GiveCPUnumber.m
index 00b7fc451..4314a0607 100644
--- a/matlab/parallel/GiveCPUnumber.m
+++ b/matlab/parallel/GiveCPUnumber.m
@@ -33,7 +33,7 @@ function [nCPU]= GiveCPUnumber (ComputerInformations, Environment)
 
 nCPU='';
 
-if nargin < 2,
+if nargin < 2
 % Determine a specific operating system or software version when necessary
 % for different command (sintax, name, ...).
 Environment=~ispc;
diff --git a/matlab/parallel/InitializeComputationalEnvironment.m b/matlab/parallel/InitializeComputationalEnvironment.m
index 02df7aad4..3a13a96ad 100644
--- a/matlab/parallel/InitializeComputationalEnvironment.m
+++ b/matlab/parallel/InitializeComputationalEnvironment.m
@@ -46,15 +46,15 @@ end
 global options_
 
 isHybridMatlabOctave = false;
-for j=1:length(options_.parallel),
-    if isempty(options_.parallel(j).MatlabOctavePath),
+for j=1:length(options_.parallel)
+    if isempty(options_.parallel(j).MatlabOctavePath)
         if isoctave
             options_.parallel(j).MatlabOctavePath = 'octave';
         else
             options_.parallel(j).MatlabOctavePath = 'matlab';
         end
     end
-    if options_.parallel(j).Local && isempty(options_.parallel(j).DynarePath),
+    if options_.parallel(j).Local && isempty(options_.parallel(j).DynarePath)
         dynareroot = strrep(which('dynare'),'dynare.m','');
         options_.parallel(j).DynarePath=dynareroot;
     end
@@ -62,7 +62,7 @@ for j=1:length(options_.parallel),
 end
 isHybridMatlabOctave = isHybridMatlabOctave && ~isoctave;
 options_.parallel_info.isHybridMatlabOctave = isHybridMatlabOctave;
-if isHybridMatlabOctave,
+if isHybridMatlabOctave
     % Reset dynare random generator and seed.
     set_dynare_seed('default');
 end
@@ -94,7 +94,7 @@ CPUWeightTemp=ones(1,lP)*(-1);
 CPUWeightTemp=CPUWeight;
 
 for i=1:lP
-    [NoNServes mP]=max(CPUWeightTemp);
+    [NoNServes, mP]=max(CPUWeightTemp);
     NewPosition(i)=mP;
     CPUWeightTemp(mP)=-1;
 end
diff --git a/matlab/parallel/closeSlave.m b/matlab/parallel/closeSlave.m
index 339d776bb..38c7d2b11 100644
--- a/matlab/parallel/closeSlave.m
+++ b/matlab/parallel/closeSlave.m
@@ -1,4 +1,4 @@
-function closeSlave(Parallel,TmpFolder,partial),
+function closeSlave(Parallel,TmpFolder,partial)
 % PARALLEL CONTEXT
 % In parallel context, this utility closes all remote matlab instances
 % called by masterParallel when strategy (1) is active i.e. always open (which leaves
@@ -32,7 +32,7 @@ function closeSlave(Parallel,TmpFolder,partial),
 % You should have received a copy of the GNU General Public License
 % along with Dynare.  If not, see <http://www.gnu.org/licenses/>.
 
-if nargin<3,
+if nargin<3
     partial=0;
 end
 
@@ -40,8 +40,8 @@ s=warning('off');
 
 if partial==1
     save('slaveParallel_break.mat','partial')
-    for indPC=1:length(Parallel),
-        if (Parallel(indPC).Local==0),
+    for indPC=1:length(Parallel)
+        if (Parallel(indPC).Local==0)
             dynareParallelSendFiles('slaveParallel_break.mat',TmpFolder,Parallel(indPC));
         end
     end
@@ -50,8 +50,8 @@ if partial==1
 end
 if partial==-1
     delete('slaveParallel_break.mat')
-    for indPC=1:length(Parallel),
-        if (Parallel(indPC).Local==0),
+    for indPC=1:length(Parallel)
+        if (Parallel(indPC).Local==0)
             dynareParallelDelete( 'slaveParallel_break.mat',TmpFolder,Parallel(indPC));
         end
     end
@@ -59,8 +59,8 @@ if partial==-1
     return
 end
 
-for indPC=1:length(Parallel),
-    if (Parallel(indPC).Local==0),
+for indPC=1:length(Parallel)
+    if (Parallel(indPC).Local==0)
         dynareParallelDelete( 'slaveParallel_input*.mat',TmpFolder,Parallel(indPC));
     end
     
@@ -74,10 +74,10 @@ for indPC=1:length(Parallel),
 end
 
 while(1)
-    if isempty(dynareParallelDir(['P_slave_',int2str(j),'End.txt'],TmpFolder,Parallel));
-        for indPC=1:length(Parallel),
-            if (Parallel(indPC).Local==0),
-                dynareParallelRmDir(TmpFolder,Parallel(indPC)),
+    if isempty(dynareParallelDir(['P_slave_',int2str(j),'End.txt'],TmpFolder,Parallel))
+        for indPC=1:length(Parallel)
+            if (Parallel(indPC).Local==0)
+                dynareParallelRmDir(TmpFolder,Parallel(indPC))
             end
         end
         break
@@ -85,5 +85,4 @@ while(1)
     end
 end
 
-s=warning('on');
- 
+s=warning('on');
\ No newline at end of file
diff --git a/matlab/parallel/distributeJobs.m b/matlab/parallel/distributeJobs.m
index 0667d902f..f763fa771 100644
--- a/matlab/parallel/distributeJobs.m
+++ b/matlab/parallel/distributeJobs.m
@@ -48,7 +48,7 @@ totCPU=0;
 lP=length(Parallel);
 CPUWeight=ones(1,length(Parallel))*(-1);
 
-for j=1:lP,    
+for j=1:lP
     if mod(length(Parallel(j).CPUnbr),Parallel(j).NumberOfThreadsPerJob)
         skipline()
         disp(['PARALLEL_ERROR:: NumberOfThreadsPerJob = ',int2str(Parallel(j).NumberOfThreadsPerJob),' is not an exact divisor of number of CPUs = ',int2str(length(Parallel(j).CPUnbr)),'!'])
@@ -77,7 +77,7 @@ NumbersOfJobs=nBlock-fBlock+1;
 SumOfJobs=0;
 JobsForNode=zeros(1,nC);
 
-for j=1:lP,
+for j=1:lP
     CPUWeight(j)=str2num(Parallel(j).NodeWeight)*nCPUoriginal(j);
 end
 CPUWeight=CPUWeight./sum(CPUWeight);
@@ -161,7 +161,7 @@ for i=1:nC
         ChekOverFlow=ChekOverFlow+JobAssignedCpu;
         
         if ChekOverFlow>=JobsForNode(i)
-            break;
+            break
         end
         
     end
@@ -204,7 +204,7 @@ for i=1:nCPU(nC)
 end
 
 for i=1:nC
-    if JobsForNode(i)~=0;
+    if JobsForNode(i)~=0
         totSLAVES=totSLAVES+1;
     end
 end
diff --git a/matlab/parallel/dynareParallelDelete.m b/matlab/parallel/dynareParallelDelete.m
index 060a35f13..97f700eed 100644
--- a/matlab/parallel/dynareParallelDelete.m
+++ b/matlab/parallel/dynareParallelDelete.m
@@ -28,20 +28,20 @@ function dynareParallelDelete(fname,pname,Parallel)
 % You should have received a copy of the GNU General Public License
 % along with Dynare.  If not, see <http://www.gnu.org/licenses/>.
 
-if nargin ==0,
+if nargin ==0
     disp('dynareParallelDelete(fname)')
     return
 end
 
-if nargin ==1,
+if nargin ==1
     pname='';
 else
     pname=[pname,filesep];
 end
 
-for indPC=1:length(Parallel),
-    if ~ispc || strcmpi('unix',Parallel(indPC).OperatingSystem),
-        if ~isempty(Parallel(indPC).Port),
+for indPC=1:length(Parallel)
+    if ~ispc || strcmpi('unix',Parallel(indPC).OperatingSystem)
+        if ~isempty(Parallel(indPC).Port)
             ssh_token = ['-p ',Parallel(indPC).Port];
         else
             ssh_token = '';
diff --git a/matlab/parallel/dynareParallelDeleteNewFiles.m b/matlab/parallel/dynareParallelDeleteNewFiles.m
index e28cd77da..b2eed497a 100644
--- a/matlab/parallel/dynareParallelDeleteNewFiles.m
+++ b/matlab/parallel/dynareParallelDeleteNewFiles.m
@@ -35,11 +35,11 @@ function dynareParallelDeleteNewFiles(PRCDir,Parallel,PRCDirSnapshot,varargin)
 NewFilesFromSlaves={};
 
 % try
-for indPC=1:length(Parallel),
+for indPC=1:length(Parallel)
     
-    if Parallel(indPC).Local==0;
+    if Parallel(indPC).Local==0
         [NewFilesFromSlaves, PRCDirSnapshot{indPC}]=dynareParallelFindNewFiles(PRCDirSnapshot{indPC},Parallel(indPC), PRCDir);
-        if ~ispc || strcmpi('unix',Parallel(indPC).OperatingSystem),
+        if ~ispc || strcmpi('unix',Parallel(indPC).OperatingSystem)
             fS='/';
         else
             fS='\';
@@ -59,7 +59,7 @@ for indPC=1:length(Parallel),
                 for indexc=1:length(varargin)
                     exception_flag=exception_flag+(~isempty(strfind(fileaddress{2},varargin{indexc})));
                 end
-                if exception_flag==0,
+                if exception_flag==0
                 dynareParallelDelete(fileaddress{2},[PRCDir,fS,fileaddress{1}],Parallel(indPC));
 
                 disp('New file deleted in remote -->');
diff --git a/matlab/parallel/dynareParallelDir.m b/matlab/parallel/dynareParallelDir.m
index daecfe6cd..445840107 100644
--- a/matlab/parallel/dynareParallelDir.m
+++ b/matlab/parallel/dynareParallelDir.m
@@ -28,10 +28,10 @@ function dirlist = dynareParallelDir(filename,PRCDir,Parallel)
 % along with Dynare.  If not, see <http://www.gnu.org/licenses/>.
 
 dirlist=[];
-for indPC=1:length(Parallel),
-    if ~ispc || strcmpi('unix',Parallel(indPC).OperatingSystem),
-        if Parallel(indPC).Local==0,
-            if ~isempty(Parallel(indPC).Port),
+for indPC=1:length(Parallel)
+    if ~ispc || strcmpi('unix',Parallel(indPC).OperatingSystem)
+        if Parallel(indPC).Local==0
+            if ~isempty(Parallel(indPC).Port)
                 ssh_token = ['-p ',Parallel(indPC).Port];
             else
                 ssh_token = '';
@@ -45,7 +45,7 @@ for indPC=1:length(Parallel),
             else
                 [check, ax]=system(['ssh ',ssh_token,' ',Parallel(indPC).UserName,'@',Parallel(indPC).ComputerName,' ls ',Parallel(indPC).RemoteDirectory,'/',PRCDir,'/',filename]);
             end
-            if check ~= 0 || ~isempty(strfind(ax,'No such file or directory'));
+            if check ~= 0 || ~isempty(strfind(ax,'No such file or directory'))
                 ax=[];
             else
                 indax=regexp(ax,'\n');
@@ -61,7 +61,7 @@ for indPC=1:length(Parallel),
                 % It is necessary to capture the ls warning message and properly manage the jolly char '*'!
                 [check ax]=system(['ls ' ,filename, ' 2> OctaveStandardOutputMessage.txt']);
                 
-                if check ~= 0 || ~isempty(strfind(ax,'No such file or directory'));
+                if check ~= 0 || ~isempty(strfind(ax,'No such file or directory'))
                     ax=[];
                 end
             else
@@ -75,32 +75,32 @@ for indPC=1:length(Parallel),
         end
     else
         if isoctave     % Patch for peculiar behaviour of ls under Windows.
-            if Parallel(indPC).Local==0,
+            if Parallel(indPC).Local==0
                 ax0=dir(['\\',Parallel(indPC).ComputerName,'\',Parallel(indPC).RemoteDrive,'$\',Parallel(indPC).RemoteDirectory,'\',PRCDir,'\',filename]);
             else
                 ax0=dir(filename);
             end
-            if isempty(ax0),
+            if isempty(ax0)
                 ax='';
             else
                 clear ax1;
-                for jax=1:length(ax0);
+                for jax=1:length(ax0)
                     ax1{jax}=ax0(jax).name;
                 end
                 ax=char(ax1{:});
             end
 
         else
-            if Parallel(indPC).Local==0,
+            if Parallel(indPC).Local==0
                 ax=ls(['\\',Parallel(indPC).ComputerName,'\',Parallel(indPC).RemoteDrive,'$\',Parallel(indPC).RemoteDirectory,'\',PRCDir,'\',filename]);
             else
                 ax=ls(filename);
             end
         end
     end
-    if isempty(dirlist),
+    if isempty(dirlist)
         dirlist=ax;
-    elseif ~isempty(ax),
+    elseif ~isempty(ax)
         dirlist = char(dirlist, ax);
     end
 end
diff --git a/matlab/parallel/dynareParallelGetFiles.m b/matlab/parallel/dynareParallelGetFiles.m
index 6dbf0539e..4e23ed6e4 100644
--- a/matlab/parallel/dynareParallelGetFiles.m
+++ b/matlab/parallel/dynareParallelGetFiles.m
@@ -33,26 +33,26 @@ function dynareParallelGetFiles(NamFileInput,PRCDir,Parallel)
 
 NamFileInput0=NamFileInput;
 
-for indPC=1:length(Parallel),
-    if Parallel(indPC).Local==0,
-        if ~ispc || strcmpi('unix',Parallel(indPC).OperatingSystem),
-            if ~isempty(Parallel(indPC).Port),
+for indPC=1:length(Parallel)
+    if Parallel(indPC).Local==0
+        if ~ispc || strcmpi('unix',Parallel(indPC).OperatingSystem)
+            if ~isempty(Parallel(indPC).Port)
                 ssh_token = ['-p ',Parallel(indPC).Port];
             else
                 ssh_token = '';
             end
-            if ~isempty(Parallel(indPC).Port),
+            if ~isempty(Parallel(indPC).Port)
                 scp_token = ['-P ',Parallel(indPC).Port];
             else
                 scp_token = '';
             end
-            if ischar(NamFileInput0),
-                for j=1:size(NamFileInput0,1),
+            if ischar(NamFileInput0)
+                for j=1:size(NamFileInput0,1)
                     NamFile(j,:)={['./'],deblank(NamFileInput0(j,:))};
                 end
                 NamFileInput = NamFile;
             end
-            for jfil=1:size(NamFileInput,1),
+            for jfil=1:size(NamFileInput,1)
 
                 if isoctave % Patch for peculiar behaviour of ls under Linux.
                     % It is necessary to manage the jolly char '*'!
@@ -92,14 +92,14 @@ for indPC=1:length(Parallel),
 
             end
         else
-            if ischar(NamFileInput0),
-                for j=1:size(NamFileInput0,1),
+            if ischar(NamFileInput0)
+                for j=1:size(NamFileInput0,1)
                     NamFile(j,:)={['.\'],deblank(NamFileInput0(j,:))};
                 end
                 NamFileInput = NamFile;
             end
-            for jfil=1:size(NamFileInput,1),
-                if ~isempty(dynareParallelDir(NamFileInput{jfil,2},[PRCDir,filesep,NamFileInput{jfil,1}],Parallel(indPC))),
+            for jfil=1:size(NamFileInput,1)
+                if ~isempty(dynareParallelDir(NamFileInput{jfil,2},[PRCDir,filesep,NamFileInput{jfil,1}],Parallel(indPC)))
                     copyfile(['\\',Parallel(indPC).ComputerName,'\',Parallel(indPC).RemoteDrive,'$\',Parallel(indPC).RemoteDirectory,'\',PRCDir,'\',NamFileInput{jfil,1},NamFileInput{jfil,2}],NamFileInput{jfil,1});
                 end
             end
diff --git a/matlab/parallel/dynareParallelGetNewFiles.m b/matlab/parallel/dynareParallelGetNewFiles.m
index 5f7eb43a3..c27711d57 100644
--- a/matlab/parallel/dynareParallelGetNewFiles.m
+++ b/matlab/parallel/dynareParallelGetNewFiles.m
@@ -36,11 +36,11 @@ function [PRCDirSnapshot]=dynareParallelGetNewFiles(PRCDir,Parallel,PRCDirSnapsh
 NewFilesFromSlaves={};
 
 % try
-for indPC=1:length(Parallel),
+for indPC=1:length(Parallel)
     
-    if Parallel(indPC).Local==0;
+    if Parallel(indPC).Local==0
         [NewFilesFromSlaves, PRCDirSnapshot{indPC}]=dynareParallelFindNewFiles(PRCDirSnapshot{indPC},Parallel(indPC), PRCDir);
-        if ~ispc || strcmpi('unix',Parallel(indPC).OperatingSystem),
+        if ~ispc || strcmpi('unix',Parallel(indPC).OperatingSystem)
             fS='/';
         else
             fS='\';
diff --git a/matlab/parallel/dynareParallelListAllFiles.m b/matlab/parallel/dynareParallelListAllFiles.m
index 53e893e15..6cb866455 100644
--- a/matlab/parallel/dynareParallelListAllFiles.m
+++ b/matlab/parallel/dynareParallelListAllFiles.m
@@ -37,14 +37,14 @@ if (~ispc || strcmpi('unix',Parallel.OperatingSystem))
    
     fileList={};
     currentPath=[];
-    if ~isempty(Parallel.Port),
+    if ~isempty(Parallel.Port)
         ssh_token = ['-p ',Parallel.Port];
     else
         ssh_token = '';
     end
 
      % Get the data for the current remote directory.
-    [Flag fL]=system(['ssh ',ssh_token,' ',' ',Parallel.UserName,'@',Parallel.ComputerName,' ls ',Parallel.RemoteDirectory,'/',PRCDir, ' -R -p -1']);
+    [Flag, fL]=system(['ssh ',ssh_token,' ',' ',Parallel.UserName,'@',Parallel.ComputerName,' ls ',Parallel.RemoteDirectory,'/',PRCDir, ' -R -p -1']);
 
     % Format the return value fL.
     
diff --git a/matlab/parallel/dynareParallelMkDir.m b/matlab/parallel/dynareParallelMkDir.m
index 9e8d7b7de..3c4466d7b 100644
--- a/matlab/parallel/dynareParallelMkDir.m
+++ b/matlab/parallel/dynareParallelMkDir.m
@@ -29,24 +29,22 @@ function dynareParallelMkDir(PRCDir,Parallel)
 
 
 
-if nargin ==0,
+if nargin ==0
     disp('dynareParallelMkDir(dirname,Parallel)')
     return
 end
 
 for indPC=1:length(Parallel)
-    if Parallel(indPC).Local==0,
-        if ~ispc || strcmpi('unix',Parallel(indPC).OperatingSystem),
-            if ~isempty(Parallel(indPC).Port),
+    if Parallel(indPC).Local==0
+        if ~ispc || strcmpi('unix',Parallel(indPC).OperatingSystem)
+            if ~isempty(Parallel(indPC).Port)
                 ssh_token = ['-p ',Parallel(indPC).Port];
             else
                 ssh_token = '';
             end
-            [NonServeS NonServeD]=system(['ssh ',ssh_token,' ',Parallel(indPC).UserName,'@',Parallel(indPC).ComputerName,' mkdir -p ',Parallel(indPC).RemoteDirectory,'/',PRCDir]);
+            [NonServeS, NonServeD]=system(['ssh ',ssh_token,' ',Parallel(indPC).UserName,'@',Parallel(indPC).ComputerName,' mkdir -p ',Parallel(indPC).RemoteDirectory,'/',PRCDir]);
         else
-            [NonServeS NonServeD]=mkdir(['\\',Parallel(indPC).ComputerName,'\',Parallel(indPC).RemoteDrive,'$\',Parallel(indPC).RemoteDirectory,'\',PRCDir]);
+            [NonServeS, NonServeD]=mkdir(['\\',Parallel(indPC).ComputerName,'\',Parallel(indPC).RemoteDrive,'$\',Parallel(indPC).RemoteDirectory,'\',PRCDir]);
         end
     end
-end
-
-return
\ No newline at end of file
+end
\ No newline at end of file
diff --git a/matlab/parallel/dynareParallelRmDir.m b/matlab/parallel/dynareParallelRmDir.m
index fbf7b7790..03c9082b0 100644
--- a/matlab/parallel/dynareParallelRmDir.m
+++ b/matlab/parallel/dynareParallelRmDir.m
@@ -30,7 +30,7 @@ function dynareParallelRmDir(PRCDir,Parallel)
 
 
 
-if nargin ==0,
+if nargin ==0
     disp('dynareParallelRmDir(fname)')
     return
 end
@@ -45,7 +45,7 @@ ok(5)=~isempty(strfind(PRCDir,'m'));
 ok(6)=~isempty(strfind(PRCDir,'s'));
 ok(7)=~isempty(PRCDir);
 
-if sum(ok)<7,
+if sum(ok)<7
     error('The name of the remote tmp folder does not comply the security standards!'),
 end
 
@@ -53,34 +53,32 @@ if isoctave
     confirm_recursive_rmdir(false, 'local');
 end
 
-for indPC=1:length(Parallel),
+for indPC=1:length(Parallel)
     ok(1)=isempty(strfind(Parallel(indPC).RemoteDirectory,'..'));
-    if sum(ok)<7,
+    if sum(ok)<7
         error('The remote folder path structure does not comply the security standards!'),
     end
     while (1)
-        if ~ispc || strcmpi('unix',Parallel(indPC).OperatingSystem),
-            if ~isempty(Parallel(indPC).Port),
+        if ~ispc || strcmpi('unix',Parallel(indPC).OperatingSystem)
+            if ~isempty(Parallel(indPC).Port)
                 ssh_token = ['-p ',Parallel(indPC).Port];
             else
                 ssh_token = '';
             end
-            [stat NonServe] = system(['ssh ',ssh_token,' ',Parallel(indPC).UserName,'@',Parallel(indPC).ComputerName,' rm -fr ',Parallel(indPC).RemoteDirectory,'/',PRCDir,]);
-            break;
+            [stat, NonServe] = system(['ssh ',ssh_token,' ',Parallel(indPC).UserName,'@',Parallel(indPC).ComputerName,' rm -fr ',Parallel(indPC).RemoteDirectory,'/',PRCDir,]);
+            break
         else
             [stat, mess, id] = rmdir(['\\',Parallel(indPC).ComputerName,'\',Parallel(indPC).RemoteDrive,'$\',Parallel(indPC).RemoteDirectory,'\',PRCDir],'s');
 
-            if stat==1,
-                break,
+            if stat==1
+                break
             else
-                if isempty(dynareParallelDir(PRCDir,'',Parallel));
-                    break,
+                if isempty(dynareParallelDir(PRCDir,'',Parallel))
+                    break
                 else
                     pause(1);
                 end
             end
         end
     end
-end
-
-return
\ No newline at end of file
+end
\ No newline at end of file
diff --git a/matlab/parallel/dynareParallelSendFiles.m b/matlab/parallel/dynareParallelSendFiles.m
index 6f7e645f5..8eed09265 100644
--- a/matlab/parallel/dynareParallelSendFiles.m
+++ b/matlab/parallel/dynareParallelSendFiles.m
@@ -32,31 +32,31 @@ function dynareParallelSendFiles(NamFileInput,PRCDir,Parallel)
 % along with Dynare.  If not, see <http://www.gnu.org/licenses/>.
 
 
-if ischar(NamFileInput),
-    for j=1:size(NamFileInput,1),
+if ischar(NamFileInput)
+    for j=1:size(NamFileInput,1)
         NamFile(j,:)={'',deblank(NamFileInput(j,:))};
     end
     NamFileInput = NamFile;
 end
 
-for indPC=1:length(Parallel),
-    if Parallel(indPC).Local==0,
-        if ~ispc || strcmpi('unix',Parallel(indPC).OperatingSystem),
-            if ~isempty(Parallel(indPC).Port),
+for indPC=1:length(Parallel)
+    if Parallel(indPC).Local==0
+        if ~ispc || strcmpi('unix',Parallel(indPC).OperatingSystem)
+            if ~isempty(Parallel(indPC).Port)
                 ssh_token = ['-p ',Parallel(indPC).Port];
             else
                 ssh_token = '';
             end
-            if ~isempty(Parallel(indPC).Port),
+            if ~isempty(Parallel(indPC).Port)
                 scp_token = ['-P ',Parallel(indPC).Port];
             else
                 scp_token = '';
             end
-            for jfil=1:size(NamFileInput,1),
+            for jfil=1:size(NamFileInput,1)
                 if ~isempty(NamFileInput{jfil,1})
-                    [NonServeL NonServeR]=system(['ssh ',ssh_token,' ',Parallel(indPC).UserName,'@',Parallel(indPC).ComputerName,' mkdir -p ',Parallel(indPC).RemoteDirectory,'/',PRCDir,'/',NamFileInput{jfil,1}]);
+                    [NonServeL, NonServeR]=system(['ssh ',ssh_token,' ',Parallel(indPC).UserName,'@',Parallel(indPC).ComputerName,' mkdir -p ',Parallel(indPC).RemoteDirectory,'/',PRCDir,'/',NamFileInput{jfil,1}]);
                 end
-                [NonServeL NonServeR]=system(['scp ',scp_token,' ',NamFileInput{jfil,1},NamFileInput{jfil,2},' ',Parallel(indPC).UserName,'@',Parallel(indPC).ComputerName,':',Parallel(indPC).RemoteDirectory,'/',PRCDir,'/',NamFileInput{jfil,1}]);
+                [NonServeL, NonServeR]=system(['scp ',scp_token,' ',NamFileInput{jfil,1},NamFileInput{jfil,2},' ',Parallel(indPC).UserName,'@',Parallel(indPC).ComputerName,':',Parallel(indPC).RemoteDirectory,'/',PRCDir,'/',NamFileInput{jfil,1}]);
             end
         else
             for jfil=1:size(NamFileInput,1)
@@ -74,14 +74,14 @@ for indPC=1:length(Parallel),
                             NamFileInputTemp=NamFileInput{jfil,1};
                             while(1)
                                 Bs=strfind(NamFileInputTemp,'/');
-                                if isempty(Bs),
-                                    break;
+                                if isempty(Bs)
+                                    break
                                 else
                                     NamFileInputTemp(1,Bs)='\';
                                 end
                             end
                             
-                            [NonServeL NonServeR]=system(['mkdir \\',Parallel(indPC).ComputerName,'\',Parallel(indPC).RemoteDrive,'$\',Parallel(indPC).RemoteDirectory,'\',PRCDir,'\',NamFileInputTemp]);
+                            [NonServeL, NonServeR]=system(['mkdir \\',Parallel(indPC).ComputerName,'\',Parallel(indPC).RemoteDrive,'$\',Parallel(indPC).RemoteDirectory,'\',PRCDir,'\',NamFileInputTemp]);
 
                         else
                             mkdir(['\\',Parallel(indPC).ComputerName,'\',Parallel(indPC).RemoteDrive,'$\',Parallel(indPC).RemoteDirectory,'\',PRCDir,'\',NamFileInput{jfil,1}]);
@@ -100,14 +100,14 @@ for indPC=1:length(Parallel),
                     NamFileInputTemp=NamFileInput{jfil,1};
                     while(1)
                         Bs=strfind(NamFileInputTemp,'/');
-                        if isempty(Bs),
-                            break;
+                        if isempty(Bs)
+                            break
                         else
                             NamFileInputTemp(1,Bs)='\';
                         end
                     end
                     
-                    [NonServeS NonServeD]=system(['copy ',NamFileInputTemp, NamFileInput{jfil,2},' \\',Parallel(indPC).ComputerName,'\',Parallel(indPC).RemoteDrive,'$\',Parallel(indPC).RemoteDirectory,'\',PRCDir,'\',NamFileInputTemp]);
+                    [NonServeS, NonServeD]=system(['copy ',NamFileInputTemp, NamFileInput{jfil,2},' \\',Parallel(indPC).ComputerName,'\',Parallel(indPC).RemoteDrive,'$\',Parallel(indPC).RemoteDirectory,'\',PRCDir,'\',NamFileInputTemp]);
                     
                 else
                     copyfile([NamFileInput{jfil,1},NamFileInput{jfil,2}],['\\',Parallel(indPC).ComputerName,'\',Parallel(indPC).RemoteDrive,'$\',Parallel(indPC).RemoteDirectory,'\',PRCDir,'\',NamFileInput{jfil,1}]);
diff --git a/matlab/parallel/dynareParallelSnapshot.m b/matlab/parallel/dynareParallelSnapshot.m
index 4f07b04df..089dd9154 100644
--- a/matlab/parallel/dynareParallelSnapshot.m
+++ b/matlab/parallel/dynareParallelSnapshot.m
@@ -33,8 +33,8 @@ function [PRCDirSnapshot]=dynareParallelSnapshot(PRCDir,Parallel)
 
 PRCDirSnapshot={};
 
-for indPC=1:length(Parallel),
-    if Parallel(indPC).Local==0;
+for indPC=1:length(Parallel)
+    if Parallel(indPC).Local==0
                                                        % The first call ...
         PRCDirSnapshot{indPC}=dynareParallelListAllFiles('Root',PRCDir,Parallel(indPC));
         
diff --git a/matlab/parallel/fMessageStatus.m b/matlab/parallel/fMessageStatus.m
index 6d84705ab..4ce6cc541 100644
--- a/matlab/parallel/fMessageStatus.m
+++ b/matlab/parallel/fMessageStatus.m
@@ -33,7 +33,7 @@ function fMessageStatus(prtfrc, njob, waitbarString, waitbarTitle, Parallel)
 
 global funcName
 
-if nargin<5,
+if nargin<5
     Parallel.Local=1;
 end
 
@@ -44,7 +44,7 @@ end
 
 fslave = dir( ['slaveParallel_input',int2str(njob),'.mat']);
 fbreak = dir( ['slaveParallel_break.mat']);
-if isempty(fslave) || ~isempty(fbreak),
+if isempty(fslave) || ~isempty(fbreak)
     error('Master asked to break the job');
 end
 
diff --git a/matlab/parallel/fParallel.m b/matlab/parallel/fParallel.m
index 51e6ebe16..d0f1d936d 100644
--- a/matlab/parallel/fParallel.m
+++ b/matlab/parallel/fParallel.m
@@ -53,7 +53,7 @@ load( [fname,'_input'])
 
 if exist('fGlobalVar') && ~isempty (fGlobalVar)
     globalVars = fieldnames(fGlobalVar);
-    for j=1:length(globalVars),
+    for j=1:length(globalVars)
         eval(['global ',globalVars{j},';'])
         evalin('base',['global ',globalVars{j},';'])
     end
@@ -67,12 +67,12 @@ fInputVar.Parallel = Parallel;
 
 
 % Launch the routine to be run in parallel.
-try,
-    tic,
+try
+    tic
     
     fOutputVar = feval(fname, fInputVar ,fblck, nblck, whoiam, ThisMatlab);
-    toc,
-    if isfield(fOutputVar,'OutputFileName'),
+    toc
+    if isfield(fOutputVar,'OutputFileName')
         OutputFileName = fOutputVar.OutputFileName;
     else
         OutputFileName = '';
@@ -81,7 +81,7 @@ try,
         % Save the output result.
         save([ fname,'_output_',int2str(whoiam),'.mat'],'fOutputVar' )
     end
-    if isfield(fOutputVar,'CloseAllSlaves'),
+    if isfield(fOutputVar,'CloseAllSlaves')
         CloseAllSlaves = 1;
         fOutputVar = rmfield(fOutputVar,'CloseAllSlaves');
         save([ fname,'_output_',int2str(whoiam),'.mat'],'fOutputVar' )
@@ -89,7 +89,7 @@ try,
     end
     
     disp(['fParallel ',int2str(whoiam),' completed.'])
-catch,
+catch
     theerror = lasterror;
     if strfind(theerror.message,'Master asked to break the job')
         fOutputVar.message = theerror;
@@ -101,7 +101,7 @@ catch,
         save([ fname,'_output_',int2str(whoiam),'.mat'],'fOutputVar' )
         waitbarString = theerror.message;
         %       waitbarTitle=['Metropolis-Hastings ',options_.parallel(ThisMatlab).ComputerName];
-        if Parallel(ThisMatlab).Local,
+        if Parallel(ThisMatlab).Local
             waitbarTitle='Local ';
         else
             waitbarTitle=[Parallel(ThisMatlab).ComputerName];
diff --git a/matlab/parallel/masterParallel.m b/matlab/parallel/masterParallel.m
index 902b237dc..7544e85e7 100644
--- a/matlab/parallel/masterParallel.m
+++ b/matlab/parallel/masterParallel.m
@@ -91,11 +91,11 @@ Strategy=Parallel_info.leaveSlaveOpen;
 
 islocal = 1;
 isHybridMatlabOctave = Parallel_info.isHybridMatlabOctave;
-for j=1:length(Parallel),
+for j=1:length(Parallel)
     islocal=islocal*Parallel(j).Local;
 end
 if nargin>8 && initialize==1
-    if islocal == 0,
+    if islocal == 0
         PRCDir=CreateTimeString();
         assignin('base','PRCDirTmp',PRCDir),
         evalin('base','options_.parallel_info.RemoteTmpFolder=PRCDirTmp;')
@@ -108,7 +108,7 @@ if nargin>8 && initialize==1
 end
 
 if isfield(Parallel_info,'local_files')
-    if isempty(NamFileInput),
+    if isempty(NamFileInput)
         NamFileInput=Parallel_info.local_files;
     else
         NamFileInput=[NamFileInput;Parallel_info.local_files];
@@ -120,26 +120,26 @@ end
 % in Octave!
 
 if isoctave
-    warning('off');
+    warning('off')
 end
 
 % check if there are function_handles in the input or global vars when
 % octave is used
 if isHybridMatlabOctave || isoctave
     fInputNames = fieldnames(fInputVar);
-    for j=1:length(fInputNames),
+    for j=1:length(fInputNames)
         TargetVar = fInputVar.(fInputNames{j});
-        if isa(TargetVar,'function_handle'),
+        if isa(TargetVar,'function_handle')
             TargetVar=func2str(TargetVar);
             fInputVar.(fInputNames{j})=TargetVar;
         end
     end
     
-    if exist('fGlobalVar','var') && ~isempty(fGlobalVar),
+    if exist('fGlobalVar','var') && ~isempty(fGlobalVar)
     fInputNames = fieldnames(fGlobalVar);
-    for j=1:length(fInputNames),
+    for j=1:length(fInputNames)
         TargetVar = fGlobalVar.(fInputNames{j});
-        if isa(TargetVar,'function_handle'),
+        if isa(TargetVar,'function_handle')
             TargetVar=func2str(TargetVar);
             fGlobalVar.(fInputNames{j})=TargetVar;
         end
@@ -156,7 +156,7 @@ end
 
 DyMo=pwd;
 % fInputVar.DyMo=DyMo;
-if ispc,
+if ispc
     [tempo, MasterName]=system('hostname');
     MasterName=deblank(MasterName);
 end
@@ -170,7 +170,7 @@ switch Strategy
         save([fname,'_input.mat'],'fInputVar','Parallel','-append')
         
     case 1
-        if exist('fGlobalVar','var'),
+        if exist('fGlobalVar','var')
             save(['temp_input.mat'],'fInputVar','fGlobalVar')
         else
             save(['temp_input.mat'],'fInputVar')
@@ -184,7 +184,7 @@ end
 % to run on each CPU.
 
 [nCPU, totCPU, nBlockPerCPU, totSlaves] = distributeJobs(Parallel, fBlock, nBlock);
-for j=1:totSlaves,
+for j=1:totSlaves
     PRCDirSnapshot{j}={};
 end
 offset0 = fBlock-1;
@@ -206,7 +206,7 @@ fid = fopen('ConcurrentCommand1.bat','w+');
 
 
 % Create the directory devoted to remote computation.
-if isempty(PRCDir) && ~islocal,
+if isempty(PRCDir) && ~islocal
     error('PRCDir not initialized!')
 else
     dynareParallelMkDir(PRCDir,Parallel(1:totSlaves));
@@ -238,7 +238,7 @@ end
 
 % End
 
-for j=1:totCPU,
+for j=1:totCPU
     
     if Strategy==1
         command1 = ' ';
@@ -253,7 +253,7 @@ for j=1:totCPU,
     % multithreading limit the performaces when the parallel computing is active.
     
     
-    if strcmp('true',Parallel(indPC).SingleCompThread),
+    if strcmp('true',Parallel(indPC).SingleCompThread)
         compThread = '-singleCompThread';
     else
         compThread = '';
@@ -273,13 +273,13 @@ for j=1:totCPU,
     fid1=fopen(['P_',fname,'_',int2str(j),'End.txt'],'w+');
     fclose(fid1);
     
-    if Strategy==1,
+    if Strategy==1
         
         fblck = offset+1;
         nblck = sum(nBlockPerCPU(1:j));
         save temp_input.mat fblck nblck fname -append;
         copyfile('temp_input.mat',['slaveJob',int2str(j),'.mat']);
-        if Parallel(indPC).Local ==0,
+        if Parallel(indPC).Local ==0
             fid1=fopen(['stayalive',int2str(j),'.txt'],'w+');
             fclose(fid1);
             dynareParallelSendFiles(['stayalive',int2str(j),'.txt'],PRCDir,Parallel(indPC));
@@ -291,10 +291,10 @@ for j=1:totCPU,
         newInstance = 0;
         
         % Check if j CPU is already alive.
-        if isempty(dynareParallelDir(['P_slave_',int2str(j),'End.txt'],PRCDir,Parallel(indPC)));
+        if isempty(dynareParallelDir(['P_slave_',int2str(j),'End.txt'],PRCDir,Parallel(indPC)))
             fid1=fopen(['P_slave_',int2str(j),'End.txt'],'w+');
             fclose(fid1);
-            if Parallel(indPC).Local==0,
+            if Parallel(indPC).Local==0
                 dynareParallelSendFiles(['P_slave_',int2str(j),'End.txt'],PRCDir,Parallel(indPC));
                 delete(['P_slave_',int2str(j),'End.txt']);
             end
@@ -312,7 +312,7 @@ for j=1:totCPU,
         
         save( ['slaveParallel_input',int2str(j),'.mat'],'j');
         
-        if Parallel(indPC).Local==0,
+        if Parallel(indPC).Local==0
             dynareParallelSendFiles(['P_',fname,'_',int2str(j),'End.txt'],PRCDir,Parallel(indPC));
             delete(['P_',fname,'_',int2str(j),'End.txt']);
             
@@ -326,7 +326,7 @@ for j=1:totCPU,
     % set affinity range on win CPU's
     affinity_range = [1:nthreads]+(j-1-nCPU0)*nthreads;
     my_affinity = int2str(Parallel(indPC).CPUnbr(affinity_range(1)));
-    for jaff=2:length(affinity_range),
+    for jaff=2:length(affinity_range)
         my_affinity = [my_affinity ',' int2str(Parallel(indPC).CPUnbr(affinity_range(jaff)))];
     end
 % % %                   int2str(Parallel(indPC).CPUnbr(j-nCPU0))
@@ -337,9 +337,9 @@ for j=1:totCPU,
     switch Strategy
         case 0
             
-            if Parallel(indPC).Local == 1,                                  % 0.1 Run on the local machine (localhost).
+            if Parallel(indPC).Local == 1                                  % 0.1 Run on the local machine (localhost).
                 
-                if ~ispc || strcmpi('unix',Parallel(indPC).OperatingSystem), % Hybrid computing Windows <-> Unix!
+                if ~ispc || strcmpi('unix',Parallel(indPC).OperatingSystem) % Hybrid computing Windows <-> Unix!
                     if regexpi([Parallel(indPC).MatlabOctavePath], 'octave') % Hybrid computing Matlab(Master)->Octave(Slaves) and Vice Versa!
                         command1=[Parallel(indPC).MatlabOctavePath,' -f --eval "default_save_options(''-v7''); addpath(''',Parallel(indPC).DynarePath,'''), dynareroot = dynare_config(); fParallel(',int2str(offset+1),',',int2str(sum(nBlockPerCPU(1:j))),',',int2str(j),',',int2str(indPC),',''',fname,''')" &'];
                     else
@@ -353,16 +353,18 @@ for j=1:totCPU,
                     end
                 end
             else                                                            % 0.2 Parallel(indPC).Local==0: Run using network on remote machine or also on local machine.
-                if j==nCPU0+1,
+                if j==nCPU0+1
                     dynareParallelSendFiles([fname,'_input.mat'],PRCDir,Parallel(indPC));
                     dynareParallelSendFiles(NamFileInput,PRCDir,Parallel(indPC));
                 end
                 
-                if (~ispc || strcmpi('unix',Parallel(indPC).OperatingSystem)), % Hybrid computing Windows <-> Unix!
-                    if ispc, token='start /B ';
-                    else token = '';
+                if (~ispc || strcmpi('unix',Parallel(indPC).OperatingSystem)) % Hybrid computing Windows <-> Unix!
+                    if ispc
+                        token='start /B ';
+                    else
+                        token = '';
                     end
-                    if ~isempty(Parallel(indPC).Port),
+                    if ~isempty(Parallel(indPC).Port)
                         ssh_token = ['-p ',Parallel(indPC).Port];
                     else
                         ssh_token = '';
@@ -370,7 +372,7 @@ for j=1:totCPU,
                     % To manage the diferences in Unix/Windows OS syntax.
                     remoteFile=['remoteDynare',int2str(j)];
                     fidRemote=fopen([remoteFile,'.m'],'w+');
-                    if regexpi([Parallel(indPC).MatlabOctavePath], 'octave'),% Hybrid computing Matlab(Master)->Octave(Slaves) and Vice Versa!
+                    if regexpi([Parallel(indPC).MatlabOctavePath], 'octave') % Hybrid computing Matlab(Master)->Octave(Slaves) and Vice Versa!
                         remoteString=['default_save_options(''-v7''); addpath(''',Parallel(indPC).DynarePath,'''), dynareroot = dynare_config(); fParallel(',int2str(offset+1),',',int2str(sum(nBlockPerCPU(1:j))),',',int2str(j),',',int2str(indPC),',''',fname,''')'];
                         command1=[token, 'ssh ',ssh_token,' ',Parallel(indPC).UserName,'@',Parallel(indPC).ComputerName,' "cd ',Parallel(indPC).RemoteDirectory,'/',PRCDir, '; ',Parallel(indPC).MatlabOctavePath,' -f --eval ',remoteFile,' " &'];
                     else
@@ -382,7 +384,7 @@ for j=1:totCPU,
                     dynareParallelSendFiles([remoteFile,'.m'],PRCDir,Parallel(indPC));
                     delete([remoteFile,'.m']);
                 else
-                    if ~strcmpi(Parallel(indPC).ComputerName,MasterName),  % 0.3 Run on a remote machine!
+                    if ~strcmpi(Parallel(indPC).ComputerName,MasterName)  % 0.3 Run on a remote machine!
                         % Hybrid computing Matlab(Master)-> Octave(Slaves) and Vice Versa!
                         if  regexpi([Parallel(indPC).MatlabOctavePath], 'octave')
                             command1=['psexec \\',Parallel(indPC).ComputerName,' -d -e -u ',Parallel(indPC).UserName,' -p ',Parallel(indPC).Password,' -W "',Parallel(indPC).RemoteDrive,':\',Parallel(indPC).RemoteDirectory,'\',PRCDir,'\" -a ',my_affinity, ...
@@ -407,8 +409,8 @@ for j=1:totCPU,
             
             
         case 1
-            if Parallel(indPC).Local == 1 && newInstance,                       % 1.1 Run on the local machine.
-                if (~ispc || strcmpi('unix',Parallel(indPC).OperatingSystem)),  % Hybrid computing Windows <-> Unix!                   
+            if Parallel(indPC).Local == 1 && newInstance                       % 1.1 Run on the local machine.
+                if (~ispc || strcmpi('unix',Parallel(indPC).OperatingSystem))  % Hybrid computing Windows <-> Unix!                   
                     if regexpi([Parallel(indPC).MatlabOctavePath], 'octave')    % Hybrid computing Matlab(Master)-> Octave(Slaves) and Vice Versa!
                         command1=[Parallel(indPC).MatlabOctavePath,' -f --eval "default_save_options(''-v7''); addpath(''',Parallel(indPC).DynarePath,'''), dynareroot = dynare_config(); slaveParallel(',int2str(j),',',int2str(indPC),')" &'];
                     else
@@ -421,21 +423,23 @@ for j=1:totCPU,
                         command1=['psexec -d -W "',DyMo, '" -a ',my_affinity,' -low  ',Parallel(indPC).MatlabOctavePath,' -nosplash -nodesktop -minimize ',compThread,' -r "addpath(''',Parallel(indPC).DynarePath,'''), dynareroot = dynare_config(); slaveParallel(',int2str(j),',',int2str(indPC),')"'];
                     end
                 end
-            elseif Parallel(indPC).Local==0,                                % 1.2 Run using network on remote machine or also on local machine.
-                if j==nCPU0+1,
+            elseif Parallel(indPC).Local==0                                % 1.2 Run using network on remote machine or also on local machine.
+                if j==nCPU0+1
                     dynareParallelSendFiles(NamFileInput,PRCDir,Parallel(indPC));
                 end
                 dynareParallelSendFiles(['P_',fname,'_',int2str(j),'End.txt'],PRCDir,Parallel(indPC));
                 delete(['P_',fname,'_',int2str(j),'End.txt']);
-                if newInstance,
+                if newInstance
                     dynareParallelSendFiles(['slaveJob',int2str(j),'.mat'],PRCDir,Parallel(indPC));
                     delete(['slaveJob',int2str(j),'.mat']);
                     dynareParallelSendFiles(['slaveParallel_input',int2str(j),'.mat'],PRCDir,Parallel(indPC))
-                    if (~ispc || strcmpi('unix',Parallel(indPC).OperatingSystem)), % Hybrid computing Windows <-> Unix!
-                        if ispc, token='start /B ';
-                        else token = '';
+                    if (~ispc || strcmpi('unix',Parallel(indPC).OperatingSystem)) % Hybrid computing Windows <-> Unix!
+                        if ispc
+                            token='start /B ';
+                        else
+                            token = '';
                         end
-                        if ~isempty(Parallel(indPC).Port),
+                        if ~isempty(Parallel(indPC).Port)
                             ssh_token = ['-p ',Parallel(indPC).Port];
                         else
                             ssh_token = '';
@@ -455,7 +459,7 @@ for j=1:totCPU,
                         dynareParallelSendFiles([remoteFile,'.m'],PRCDir,Parallel(indPC));
                         delete([remoteFile,'.m']);
                     else
-                        if ~strcmpi(Parallel(indPC).ComputerName,MasterName), % 1.3 Run on a remote machine.
+                        if ~strcmpi(Parallel(indPC).ComputerName,MasterName) % 1.3 Run on a remote machine.
                             % Hybrid computing Matlab(Master)->Octave(Slaves) and Vice Versa!
                             if  regexpi([Parallel(indPC).MatlabOctavePath], 'octave')
                                 command1=['psexec \\',Parallel(indPC).ComputerName,' -d -e -u ',Parallel(indPC).UserName,' -p ',Parallel(indPC).Password,' -W "',Parallel(indPC).RemoteDrive,':\',Parallel(indPC).RemoteDirectory,'\',PRCDir,'\" -a ',my_affinity, ...
@@ -480,7 +484,7 @@ for j=1:totCPU,
                     % do PRCDirSnapshot here to to avoid problems of
                     % synchronization.
                     
-                    if isempty(PRCDirSnapshot{indPC}),
+                    if isempty(PRCDirSnapshot{indPC})
                         PRCDirSnapshot(indPC)=dynareParallelSnapshot(PRCDir,Parallel(indPC));
                         PRCDirSnapshotInit(indPC) = PRCDirSnapshot(indPC);
                     else
@@ -511,12 +515,12 @@ end
 % the slaves ...
 % If the compuation is 'Local' it is not necessary to do it ...
 
-if Strategy==0 || newInstance, % See above.
+if Strategy==0 || newInstance % See above.
     PRCDirSnapshot=dynareParallelSnapshot(PRCDir,Parallel(1:totSlaves));
     PRCDirSnapshotInit = PRCDirSnapshot;
     
     % Run the slaves.
-    if  ~ispc,
+    if  ~ispc
         system('sh ConcurrentCommand1.bat &');
         pause(1)
     else
@@ -569,7 +573,7 @@ else
     set(hstatus(1),'Units','normalized'),
     vspace = max(0.1,1/totCPU);
     vstart = 1-vspace+0.2*vspace;
-    for j=1:totCPU,
+    for j=1:totCPU
         jrow = mod(j-1,10)+1;
         jcol = ceil(j/10);
         hstatus(j) = axes('position',[0.05/ncol+(jcol-1)/ncol vstart-vspace*(jrow-1) 0.9/ncol 0.3*vspace], ...
@@ -615,7 +619,7 @@ if options_.console_mode ||  isoctave
     end
     
     for i=1:L
-        if  fnameTemp(i)=='_';
+        if  fnameTemp(i)=='_'
             fnameTemp(i)=' ';
         end
     end
@@ -657,18 +661,18 @@ while (ForEver)
     pause(1)
     
     try
-        if islocal ==0,
+        if islocal ==0
             dynareParallelGetFiles(['comp_status_',fname,'*.mat'],PRCDir,Parallel(1:totSlaves));
         end
     catch
     end
     
-    for j=1:totCPU,
+    for j=1:totCPU
         try
             if ~isempty(['comp_status_',fname,int2str(j),'.mat'])
                 load(['comp_status_',fname,int2str(j),'.mat']);
 %                 whoCloseAllSlaves = who(['comp_status_',fname,int2str(j),'.mat','CloseAllSlaves']);
-                if exist('CloseAllSlaves') && flag_CloseAllSlaves==0,
+                if exist('CloseAllSlaves') && flag_CloseAllSlaves==0
                     flag_CloseAllSlaves=1;
                     whoiamCloseAllSlaves=j;
                     closeSlave(Parallel(1:totSlaves),PRCDir,1);
@@ -706,7 +710,7 @@ while (ForEver)
             end
         end
     else
-        for j=1:totCPU,
+        for j=1:totCPU
             try
                 set(hpat(j),'XData',[0 0 pcerdone(j) pcerdone(j)]);
                 set(htit(j),'String',[status_Title{j},' - ',status_String{j}]);
@@ -729,9 +733,9 @@ while (ForEver)
         PRCDirSnapshot=dynareParallelGetNewFiles(PRCDir,Parallel(1:totSlaves),PRCDirSnapshot);
     end
     
-    if isempty(dynareParallelDir(['P_',fname,'_*End.txt'],PRCDir,Parallel(1:totSlaves)));
+    if isempty(dynareParallelDir(['P_',fname,'_*End.txt'],PRCDir,Parallel(1:totSlaves)))
         HoTuttiGliOutput=0;
-        for j=1:totCPU,
+        for j=1:totCPU
             
             % Checking if the remote computation is finished and if we copied all the output here.
             if ~isempty(dir([fname,'_output_',int2str(j),'.mat']))
@@ -742,7 +746,7 @@ while (ForEver)
             end
         end
         
-        if HoTuttiGliOutput==totCPU,
+        if HoTuttiGliOutput==totCPU
             mydelete(['comp_status_',fname,'*.mat']);
             if isoctave || options_.console_mode
                 if isoctave
@@ -754,7 +758,7 @@ while (ForEver)
                 end
                 diary on;
             else
-                close(hfigstatus),
+                close(hfigstatus)
             end
             
             break
@@ -770,19 +774,19 @@ end
 iscrash = 0;
 PRCDirSnapshot=dynareParallelGetNewFiles(PRCDir,Parallel(1:totSlaves),PRCDirSnapshot);
 
-for j=1:totCPU,
+for j=1:totCPU
     indPC=min(find(nCPU>=j));
     load([fname,'_output_',int2str(j),'.mat'],'fOutputVar');
     delete([fname,'_output_',int2str(j),'.mat']);
-    if isfield(fOutputVar,'OutputFileName') && Parallel(indPC).Local==0,
+    if isfield(fOutputVar,'OutputFileName') && Parallel(indPC).Local==0
         %   Check if input files have been updated!
         OutputFileName=fOutputVar.OutputFileName;        
         tmp0='';
-        for i=1:size(NamFileInput,1),
+        for i=1:size(NamFileInput,1)
             FileList = regexp(strrep(PRCDirSnapshot{indPC},'\','/'),strrep(strrep([NamFileInput{i,:}],'\','/'),'*','(\w*)'),'match');
-            for k=1:length(FileList),
-                if ~isempty(FileList{k}),
-                    if isempty(tmp0),
+            for k=1:length(FileList)
+                if ~isempty(FileList{k})
+                    if isempty(tmp0)
                         tmp0=FileList{k}{1};
                     else
                         tmp0=char(tmp0,FileList{k}{1});
@@ -790,74 +794,74 @@ for j=1:totCPU,
                 end
             end
         end
-        for i=1:size(OutputFileName,1),
+        for i=1:size(OutputFileName,1)
             tmp1='';
             FileList = regexp(cellstr(tmp0),strrep(strrep([OutputFileName{i,:}],'\','/'),'*','(\w*)'),'match');
             FileList0 = regexp(cellstr(tmp0),strrep([OutputFileName{i,2}],'*','(\w*)'),'match');
-            for k=1:length(FileList),
-                if ~isempty(FileList{k}),
-                    if isempty(tmp1),
+            for k=1:length(FileList)
+                if ~isempty(FileList{k})
+                    if isempty(tmp1)
                         tmp1=FileList0{k}{1};
                     else
                         tmp1=char(tmp1,FileList0{k}{1});
                     end
                 end
             end
-            for k=1:size(tmp1,1),
+            for k=1:size(tmp1,1)
                     dynareParallelGetFiles([OutputFileName(i,1) {tmp1(k,:)}],PRCDir,Parallel(indPC));
             end
         end
         % check if some output file is missing!
-        for i=1:size(OutputFileName,1),
+        for i=1:size(OutputFileName,1)
             tmp1=dynareParallelDir([OutputFileName{i,:}],PRCDir,Parallel(indPC));
             tmp1 = regexp(cellstr(tmp1),strrep([OutputFileName{i,2}],'*','(\w*)'),'match');
             tmp1 = char(tmp1{:});
             tmp2=ls([OutputFileName{i,:}]);
-            for ij=1:size(tmp1,1),
+            for ij=1:size(tmp1,1)
                 icheck = regexp(cellstr(tmp2),tmp1(ij,:),'once');
                 isOutputFileMissing=1;
-                for ik=1:size(tmp2,1),
-                    if ~isempty(icheck{ik}),
+                for ik=1:size(tmp2,1)
+                    if ~isempty(icheck{ik})
                         isOutputFileMissing=0;
                     end
                 end
-                if isOutputFileMissing,
+                if isOutputFileMissing
                     dynareParallelGetFiles([OutputFileName(i,1) {tmp1(ij,:)}],PRCDir,Parallel(indPC));
                 end
             end
         end
 
     end
-    if isfield(fOutputVar,'error'),
+    if isfield(fOutputVar,'error')
         disp(['Job number ',int2str(j),' crashed with error:']);
         iscrash=1;
         disp([fOutputVar.error.message]);
         for jstack=1:length(fOutputVar.error.stack)
-            fOutputVar.error.stack(jstack),
+            fOutputVar.error.stack(jstack)
         end
-    elseif flag_CloseAllSlaves==0,
+    elseif flag_CloseAllSlaves==0
         fOutVar(j)=fOutputVar;
-    elseif j==whoiamCloseAllSlaves,
+    elseif j==whoiamCloseAllSlaves
         fOutVar=fOutputVar;        
     end
 end
 
-if flag_CloseAllSlaves==1,
+if flag_CloseAllSlaves==1
     closeSlave(Parallel(1:totSlaves),PRCDir,-1);
 end
 
-if iscrash,
+if iscrash
     error('Remote jobs crashed');
 end
 
-pause(1), % Wait for all remote diary off completed
+pause(1) % Wait for all remote diary off completed
 
 % Cleanup.
 dynareParallelGetFiles('*.log',PRCDir,Parallel(1:totSlaves));
 
 switch Strategy
     case 0
-        for indPC=1:min(find(nCPU>=totCPU)),
+        for indPC=1:min(find(nCPU>=totCPU))
             if Parallel(indPC).Local == 0
                 dynareParallelRmDir(PRCDir,Parallel(indPC));
             end
@@ -879,21 +883,21 @@ switch Strategy
         delete ConcurrentCommand1.bat
     case 1
         delete(['temp_input.mat'])
-        if newInstance,
+        if newInstance
             if isempty(dir('dynareParallelLogFiles'))
                 [A B C]=rmdir('dynareParallelLogFiles');
                 mkdir('dynareParallelLogFiles');
             end
         end
         copyfile('*.log','dynareParallelLogFiles');
-        if newInstance,
+        if newInstance
             delete ConcurrentCommand1.bat
         end
         dynareParallelDelete(['comp_status_',fname,'*.mat'],PRCDir,Parallel);
-        for indPC=1:min(find(nCPU>=totCPU)),
-            if Parallel(indPC).Local == 0,
+        for indPC=1:min(find(nCPU>=totCPU))
+            if Parallel(indPC).Local == 0
                 dynareParallelDeleteNewFiles(PRCDir,Parallel(indPC),PRCDirSnapshotInit(indPC),'.log');
-                for ifil=1:size(NamFileInput,1),
+                for ifil=1:size(NamFileInput,1)
                     dynareParallelDelete([NamFileInput{ifil,:}],PRCDir,Parallel(indPC));
                 end
             end
diff --git a/matlab/parallel/slaveParallel.m b/matlab/parallel/slaveParallel.m
index d7275a4fd..6b4acdce4 100644
--- a/matlab/parallel/slaveParallel.m
+++ b/matlab/parallel/slaveParallel.m
@@ -48,9 +48,9 @@ dynareroot = dynare_config();
 load( ['slaveParallel_input',int2str(whoiam)]);
 
 %Loads fGlobalVar Parallel.
-if exist('fGlobalVar'),
+if exist('fGlobalVar')
     globalVars = fieldnames(fGlobalVar);
-    for j=1:length(globalVars),
+    for j=1:length(globalVars)
         eval(['global ',globalVars{j},';']);
         evalin('base',['global ',globalVars{j},';']);
     end
@@ -65,17 +65,17 @@ end
 t0=clock;
 fslave = dir( ['slaveParallel_input',int2str(whoiam),'.mat']);
 
-while (etime(clock,t0)<1200 && ~isempty(fslave)) || ~isempty(dir(['stayalive',int2str(whoiam),'.txt'])),
-    if ~isempty(dir(['stayalive',int2str(whoiam),'.txt'])),
+while (etime(clock,t0)<1200 && ~isempty(fslave)) || ~isempty(dir(['stayalive',int2str(whoiam),'.txt']))
+    if ~isempty(dir(['stayalive',int2str(whoiam),'.txt']))
         t0=clock;
         delete(['stayalive',int2str(whoiam),'.txt']);
     end
     % I wait for 20 min or while mater asks to exit (i.e. it cancels fslave file)
-    pause(1);
+    pause(1)
     
     fjob = dir(['slaveJob',int2str(whoiam),'.mat']);
     
-    if ~isempty(fjob),
+    if ~isempty(fjob)
         clear fGlobalVar fInputVar fblck nblck fname
         
         while(1)
@@ -85,7 +85,7 @@ while (etime(clock,t0)<1200 && ~isempty(fslave)) || ~isempty(dir(['stayalive',in
             
             if Go>0    
                 fclose(Go);
-                pause(1);
+                pause(1)
                 load(['slaveJob',int2str(whoiam),'.mat']);
                 break
             else
@@ -106,9 +106,9 @@ while (etime(clock,t0)<1200 && ~isempty(fslave)) || ~isempty(dir(['stayalive',in
 
         if exist('fGlobalVar') && ~isempty (fGlobalVar)
             globalVars = fieldnames(fGlobalVar);
-            for j=1:length(globalVars),
+            for j=1:length(globalVars)
                 info_whos = whos(globalVars{j});
-                if isempty(info_whos) || ~info_whos.global,
+                if isempty(info_whos) || ~info_whos.global
                     eval(['global ',globalVars{j},';']);
                     evalin('base',['global ',globalVars{j},';']);
                 end
@@ -122,11 +122,11 @@ while (etime(clock,t0)<1200 && ~isempty(fslave)) || ~isempty(dir(['stayalive',in
         fInputVar.Parallel = Parallel;
         
         % Launch the routine to be run in parallel.
-        try,
-            tic,
+        try
+            tic
             fOutputVar = feval(fname, fInputVar ,fblck, nblck, whoiam, ThisMatlab);
-            toc,
-            if isfield(fOutputVar,'OutputFileName'),
+            toc
+            if isfield(fOutputVar,'OutputFileName')
                 OutputFileName = fOutputVar.OutputFileName;
             else
                 OutputFileName = '';
@@ -137,7 +137,7 @@ while (etime(clock,t0)<1200 && ~isempty(fslave)) || ~isempty(dir(['stayalive',in
                 % Save the output result.
                 save([ fname,'_output_',int2str(whoiam),'.mat'],'fOutputVar' );
 %                 keyboard,
-                if isfield(fOutputVar,'CloseAllSlaves'),
+                if isfield(fOutputVar,'CloseAllSlaves')
                     CloseAllSlaves = 1;
                     fOutputVar = rmfield(fOutputVar,'CloseAllSlaves');
                     save([ fname,'_output_',int2str(whoiam),'.mat'],'fOutputVar' )
@@ -150,7 +150,7 @@ while (etime(clock,t0)<1200 && ~isempty(fslave)) || ~isempty(dir(['stayalive',in
 
             disp(['Job ',fname,' on CPU ',int2str(whoiam),' completed.']);
             t0 =clock; % Re-set waiting time of 20 mins
-        catch,
+        catch
             theerror = lasterror;
             if strfind(theerror.message,'Master asked to break the job')
                 disp(['Job ',fname,' on CPU ',int2str(whoiam),' broken from master.']);
@@ -162,7 +162,7 @@ while (etime(clock,t0)<1200 && ~isempty(fslave)) || ~isempty(dir(['stayalive',in
                 fOutputVar.error = lasterror;
                 save([ fname,'_output_',int2str(whoiam),'.mat'],'fOutputVar' );
                 waitbarString = fOutputVar.error.message;
-                if Parallel(ThisMatlab).Local,
+                if Parallel(ThisMatlab).Local
                     waitbarTitle='Local ';
                 else
                     waitbarTitle=[Parallel(ThisMatlab).ComputerName];
diff --git a/matlab/parallel/storeGlobalVars.m b/matlab/parallel/storeGlobalVars.m
index cd0470c37..ce80ec189 100644
--- a/matlab/parallel/storeGlobalVars.m
+++ b/matlab/parallel/storeGlobalVars.m
@@ -32,12 +32,12 @@ function storeGlobalVars(fname,append)
 
 GlobalNames = who('global');
 % varlist = '';
-for j=1:length(GlobalNames);
+for j=1:length(GlobalNames)
     eval(['global ',GlobalNames{j},';']);
     eval(['fGlobalVar.',GlobalNames{j},'=',GlobalNames{j},';']);
 end
 
-if nargin<2,
+if nargin<2
     save(fname,'fGlobalVar');
 else
     save(fname,'fGlobalVar','-append');
diff --git a/matlab/parallel/struct2local.m b/matlab/parallel/struct2local.m
index fbe9666f0..e77fa2274 100644
--- a/matlab/parallel/struct2local.m
+++ b/matlab/parallel/struct2local.m
@@ -30,6 +30,6 @@ function struct2local(S)
 
 vnam = fieldnames(S);
 
-for j=1:length(vnam),
+for j=1:length(vnam)
     assignin('caller',vnam{j},getfield(S,vnam{j}));
 end
diff --git a/matlab/partial_information/PCL_Part_info_irf.m b/matlab/partial_information/PCL_Part_info_irf.m
index 2fc0ff1d8..31162930c 100644
--- a/matlab/partial_information/PCL_Part_info_irf.m
+++ b/matlab/partial_information/PCL_Part_info_irf.m
@@ -132,7 +132,7 @@ stderr=diag(M_.Sigma_e^0.5);
 irfmat=zeros(size(dr.PI_TT1 ,1),irfpers+1);
 irfst=zeros(size(GG,1),irfpers+1); 
 irfst(:,1)=stderr(ii)*imp(:,ii);
-for jj=2:irfpers+1;
+for jj=2:irfpers+1
     irfst(:,jj)=GG*irfst(:,jj-1);
     irfmat(:,jj-1)=VV*irfst(NX+1:ss-FL_RANK,jj);
 end   
diff --git a/matlab/partial_information/PCL_Part_info_moments.m b/matlab/partial_information/PCL_Part_info_moments.m
index fdebe317f..d81a2bfe1 100644
--- a/matlab/partial_information/PCL_Part_info_moments.m
+++ b/matlab/partial_information/PCL_Part_info_moments.m
@@ -48,7 +48,7 @@ LL = sparse(1:NOBS,OBS,ones(NOBS,1),NY,NY);
 
 if exist( 'irfpers')==1
     if ~isempty(irfpers)
-        if irfpers<=0, irfpers=20, end;
+        if irfpers<=0, irfpers=20, end
     else
         irfpers=20;
     end
@@ -170,7 +170,7 @@ ar = options_.ar;
 if ar > 0
     COV_YRk= zeros(nn,ar); 
     AutoCOR_YRk= zeros(nn,ar); 
-    for k=1:ar;
+    for k=1:ar
         COV_P=GAM*COV_P;
         COV_OMEGA= COV_P( end-nn+1:end, end-nn+1:end);
         COV_YRk = VV*COV_OMEGA*VV';
diff --git a/matlab/partial_information/PI_gensys.m b/matlab/partial_information/PI_gensys.m
index c46d45d07..eb8ba6a94 100644
--- a/matlab/partial_information/PI_gensys.m
+++ b/matlab/partial_information/PI_gensys.m
@@ -96,7 +96,7 @@ try
         else
             warning('PI_gensys: Evading inversion of zero matrix UAVinv=inv(U02''*a1*V02)!');
             eu=[0,0];
-            return;
+            return
         end
     end
 catch
@@ -171,7 +171,7 @@ if(options_.ACES_solver==1)
             zeros(num_inst,size(E3,2)), II;
           ];
     eu =[1; 1], nmat=[], gev=[];
-    return; % do not check B&K compliancy
+    return % do not check B&K compliancy
 end
 
 G0pi=eye(n+FL_RANK+NX);
diff --git a/matlab/partial_information/PI_gensys_singularC.m b/matlab/partial_information/PI_gensys_singularC.m
index 5dc26ec63..426a05d6a 100644
--- a/matlab/partial_information/PI_gensys_singularC.m
+++ b/matlab/partial_information/PI_gensys_singularC.m
@@ -86,7 +86,4 @@ catch
     [errmsg, errcode]=lasterr;
     warning(['error callig PI_gensys_singularC: ' errmsg ],'errcode');
     error('errcode',['error callig PI_gensys_singularC: ' errmsg ]);
-end
-
-return;
-
+end
\ No newline at end of file
diff --git a/matlab/partial_information/add_auxiliary_variables_to_steadystate.m b/matlab/partial_information/add_auxiliary_variables_to_steadystate.m
index d99e36ebb..3524dae18 100644
--- a/matlab/partial_information/add_auxiliary_variables_to_steadystate.m
+++ b/matlab/partial_information/add_auxiliary_variables_to_steadystate.m
@@ -21,7 +21,7 @@ function ys1 = add_auxiliary_variables_to_steadystate(ys,aux_vars,fname, ...
 n = length(aux_vars);
 ys1 = [ys;zeros(n,1)];
 
-for i=1:n+1;
+for i=1:n+1
     if byte_code
         [info, res] = bytecode('static','evaluate',ys1,...
                                [exo_steady_state; ...
@@ -30,7 +30,7 @@ for i=1:n+1;
         res = feval([fname '_static'],ys1,...
                     [exo_steady_state; ...
                      exo_det_steady_state],params);
-    end;
+    end
     for j=1:n
         el = aux_vars(j).endo_index;
         ys1(el) = ys1(el)-res(el);
diff --git a/matlab/partial_information/dr1_PI.m b/matlab/partial_information/dr1_PI.m
index 0475d4bef..2fca86272 100644
--- a/matlab/partial_information/dr1_PI.m
+++ b/matlab/partial_information/dr1_PI.m
@@ -451,6 +451,4 @@ end % end if useAIM and...
 
     % TODO: 
     % if options_.loglinear == 1
-    % if exogenous deterministic variables
-    
-    return;
+    % if exogenous deterministic variables
\ No newline at end of file
diff --git a/matlab/perfect-foresight-models/det_cond_forecast.m b/matlab/perfect-foresight-models/det_cond_forecast.m
index 38d72d345..4b143f3f5 100644
--- a/matlab/perfect-foresight-models/det_cond_forecast.m
+++ b/matlab/perfect-foresight-models/det_cond_forecast.m
@@ -35,7 +35,7 @@ initial_conditions = oo_.steady_state;
 verbosity = options_.verbosity;
 if options_.periods == 0
 	options_.periods = 25;
-end;
+end
 %We have to get an initial guess for the conditional forecast 
 % and terminal conditions for the non-stationary variables, we
 % use the first order approximation of the rational expectation solution.
@@ -64,7 +64,7 @@ if length(varargin) > 3
     nvars = length(constrained_vars);
     for i = 1:max_periods_simulation
         constraint_index{i} = 1:nvars;
-    end;
+    end
     direct_mode = 0;
     shocks_present = 0;
     controlled_varexo = options_cond_fcst.controlled_varexo;
@@ -193,24 +193,24 @@ else
                     end
                 end
                 data_set = merge(dset(dset.dates(1):(plan.date(1)-1)), data_set);
-                return;
+                return
                 union_names = union(data_set.name, dset.name);
                 dif = setdiff(union_names, data_set.name);
                 data_set_nobs = data_set.nobs;
                 for i = 1:length(dif)
                     data_set{dif{i}} = dseries(nan(data_set_nobs,1),plan.date(1), dif(i), dif(i));
-                end;
+                end
                 dif = setdiff(union_names, dset.name);
                 dset_nobs = dset.nobs;
                 for i = 1:length(dif)
                     dset{dif{i}} = dseries(nan(dset_nobs,1),dset.dates(1), dif(i), dif(i));
-                end;
+                end
                 data_set = [dset(dset.dates(1):(plan.date(1)-1)) ; data_set];
-                return;
-            end;
+                return
+            end
         else
            error('impossible case'); 
-        end;
+        end
             
     else
         oo_.exo_simul = repmat(oo_.exo_steady_state',options_.periods+2,1);
@@ -235,7 +235,7 @@ else
     
     total_periods = plan.date;
     
-end;
+end
 
 if ~isfield(options_cond_fcst,'periods') || isempty(options_cond_fcst.periods)
     options_cond_fcst.periods = 100;
@@ -260,7 +260,7 @@ if direct_mode == 1
         else
             init_periods = period_i;
             tp_end = period_i;
-        end;
+        end
         tp0 = tp;
         while tp < init_periods
             tp = tp + 1;
@@ -271,18 +271,18 @@ if direct_mode == 1
             constrained_paths(i, tp - tp0 + 1) = constrained_paths_cell{i}(j + 1);
             tp = tp + 1;
             j = j + 1;
-        end;
+        end
         if tp - tp0 > max_periods_simulation 
             max_periods_simulation = tp - tp0;
-        end;
+        end
     end
     n_nnz = length(sum(is_constraint,2));
     if n_nnz > 0
         constraint_index = cell(n_nnz,1);
         for i= 1:n_nnz
             constraint_index{i} = find(is_constraint(i,:));
-        end;
-    end;
+        end
+    end
     if shocks_present
         n_periods = length(shock_periods);
         shock_paths_cell = shock_paths;
@@ -299,7 +299,7 @@ if direct_mode == 1
             else
                 init_periods = period_i;
                 tp_end = period_i;
-            end;
+            end
             tp0 = tp;
             while tp < init_periods
                 tp = tp + 1;
@@ -310,17 +310,17 @@ if direct_mode == 1
                 shock_paths(i, tp - tp0 + 1) = shock_paths_cell{i}(j + 1);
                 tp = tp + 1;
                 j = j + 1;
-            end;
+            end
             if tp - tp0 > max_periods_simulation 
                 max_periods_simulation = tp - tp0;
-            end;
-        end;
+            end
+        end
         n_nnz = length(sum(is_shock,2));
         if n_nnz > 0
             shock_index = cell(n_nnz, 1);
             for i= 1:n_nnz
                 shock_index{i} = find(is_shock(i,:));
-            end;
+            end
         end
     end
 else
@@ -342,10 +342,10 @@ if isfield(options_cond_fcst,'controlled_varexo')
     n_control_exo = size(options_cond_fcst.controlled_varexo, 1);
     if n_control_exo ~= n_endo_constrained
         error(['det_cond_forecast: the number of exogenous controlled variables (' int2str(n_control_exo) ') has to be equal to the number of constrained endogenous variabes (' int2str(n_endo_constrained) ')'])
-    end;
+    end
 else
     error('det_cond_forecast: to run a deterministic conditional forecast you have to specified the exogenous variables controlled using the option controlled_varexo in forecast command');
-end;
+end
 
 % if n_endo_constrained == 0
 %     options_.ep.use_bytecode = options_.bytecode;
@@ -377,14 +377,14 @@ if isempty(indx_endo_solve_pf)
     pf = 0;
 else
     pf = length(indx_endo_solve_pf);
-end;
+end
 indx_endo_solve_surprise = setdiff(constrained_vars, indx_endo_solve_pf);
 
 if isempty(indx_endo_solve_surprise)
     surprise = 0;
 else
     surprise = length(indx_endo_solve_surprise);
-end;
+end
 
 
 eps = options_.solve_tolf;
@@ -414,7 +414,7 @@ if pf && ~surprise
     for j = 1:length(constrained_vars)
         indx_endo(col_count : col_count + constrained_periods - 1) = constrained_vars(j) + (time_index_constraint - 1) * ny;
         col_count = col_count + constrained_periods;
-    end;
+    end
     oo_=make_ex_(M_,options_,oo_);
     oo_=make_y_(M_,options_,oo_);
     it = 1;
@@ -436,9 +436,9 @@ if pf && ~surprise
                     y = oo_.endo_simul(constrained_vars(j), time_index_constraint);
                     r(col_count:col_count+constrained_periods - 1) = (y - constrained_paths(j,1:constrained_periods))';
                     col_count = col_count + constrained_periods;
-                end;
+                end
                 normr = norm(r, 1);
-            end;
+            end
             if (~oo_.deterministic_simulation.status || ~result || normr > normra) && it > 1
                 not_achieved = 1;
                 alpha = alpha / 2;
@@ -446,13 +446,13 @@ if pf && ~surprise
                 for j = controlled_varexo'
                     oo_.exo_simul(time_index_constraint,j) = (old_exo(:,j) + alpha * D_exo(col_count: (col_count + constrained_periods - 1)));
                     col_count = col_count + constrained_periods;
-                end;
+                end
                 disp(['Divergence in  Newton: reducing the path length alpha=' num2str(alpha)]);
                 oo_.endo_simul = repmat(oo_.steady_state, 1, options_cond_fcst.periods + 2);
             else
                 not_achieved = 0;
-            end;
-        end;
+            end
+        end
         
         per = 30;
         z = oo_.endo_simul(:, 1 : per + 2 );
@@ -473,7 +473,7 @@ if pf && ~surprise
                 else
                     data1 = M_;
                     Size = 1;
-                end;
+                end
                 data1 = M_;
                 if (options_.bytecode)
                     [chck, zz, data1]= bytecode('dynamic','evaluate', z, zx, M_.params, oo_.steady_state, k, data1);
@@ -482,16 +482,16 @@ if pf && ~surprise
                     data1.g1_x = g1b(:,end - M_.exo_nbr + 1:end);
                     data1.g1 = g1b(:,1 : end - M_.exo_nbr);
                     chck = 0;
-                end;
+                end
                 mexErrCheck('bytecode', chck);
-            end;
+            end
             if k == 1 
                 g1(1:M_.endo_nbr,-M_.endo_nbr + [cur_indx lead_indx]) = data1.g1(:,M_.nspred + 1:end);
             elseif k == per
                 g1(M_.endo_nbr * (k - 1) + 1 :M_.endo_nbr * k,M_.endo_nbr * (k -2) + [lag_indx cur_indx]) = data1.g1(:,1:M_.nspred + M_.endo_nbr);
             else
                 g1(M_.endo_nbr * (k - 1) + 1 :M_.endo_nbr * k, M_.endo_nbr * (k -2) + [lag_indx cur_indx lead_indx]) = data1.g1;
-            end;
+            end
             l2 = 1;
             pf_c = 1;
             if k <= constrained_periods
@@ -504,16 +504,16 @@ if pf && ~surprise
                         for ii = 2:constrained_periods
                             indx_x(l2) = length(controlled_varexo) + pf * (ii - 2) + constraint_index{k + ii - 1}(pf_c);
                             l2 = l2 + 1;
-                        end;
+                        end
                         pf_c = pf_c + 1;
                         cum_index_d_y_x = [cum_index_d_y_x; constrained_vars(l)];
                     else
                         cum_index_d_y_x = [cum_index_d_y_x; constrained_vars(l) + (k - 1) * M_.endo_nbr];
                     end
                     cum_l1 = cum_l1 + length(l1);
-                end;
-            end;
-        end;
+                end
+            end
+        end
         
         d_y_x = - g1 \ g1_x;
 
@@ -533,7 +533,7 @@ if pf && ~surprise
                 cum_l1 = cum_l1 + length(l1);
             end
             cum_l1 = cum_l1 + length(constrained_vars(j1));
-        end;
+        end
         
         
 %         col_count = 1;
@@ -545,8 +545,8 @@ if pf && ~surprise
 %                 J1(:,col_count) = (oo_.endo_simul(indx_endo) - ys) / eps1;
 %                 oo_.exo_simul(time,j) = saved;
 %                 col_count = col_count + 1;
-%             end;
-%         end;
+%             end
+%         end
 %         J1
 %         sdfmlksdf;
         
@@ -564,11 +564,11 @@ if pf && ~surprise
             for j = controlled_varexo'
                 oo_.exo_simul(time_index_constraint,j) = oo_.exo_simul(time_index_constraint,j) + D_exo(col_count: (col_count + constrained_periods - 1));
                 col_count = col_count + constrained_periods - 1;
-            end;
-        end;
+            end
+        end
         it = it + 1;
         normra = normr;
-    end;
+    end
     endo = oo_.endo_simul';
     exo = oo_.exo_simul;
 else
@@ -581,7 +581,7 @@ else
                 pf = 0;
             else
                 pf = length(indx_endo_solve_pf);
-            end;
+            end
         
             [pos_constrained_surprise, junk] = find((1-constrained_perfect_foresight) .* is_constraint(t, :)');
             indx_endo_solve_surprise = constrained_vars(pos_constrained_surprise);
@@ -590,8 +590,8 @@ else
                 surprise = 0;
             else
                 surprise = length(indx_endo_solve_surprise);
-            end;
-        end;
+            end
+        end
         
         if direct_mode && ~isempty(is_shock) 
             [pos_shock_pf, junk] = find(shock_perfect_foresight .* is_shock(t, :)');
@@ -600,7 +600,7 @@ else
                 b_pf = 0;
             else
                 b_pf = length(indx_endo_solve_pf);
-            end;
+            end
         
             [pos_shock_surprise, junk] = find((1-shock_perfect_foresight) .* is_shock(t, :)');
             indx_endo_solve_surprise = shock_vars(pos_shock_surprise);
@@ -609,8 +609,8 @@ else
                 b_surprise = 0;
             else
                 b_surprise = length(indx_endo_solve_surprise);
-            end;
-        end;
+            end
+        end
         
         disp('===============================================================================================');
         disp(['t=' int2str(t) ' conditional (surprise=' int2str(surprise) ' perfect foresight=' int2str(pf) ') unconditional (surprise=' int2str(b_surprise) ' perfect foresight=' int2str(b_pf) ')']);
@@ -623,7 +623,7 @@ else
                 exo_init = zeros(size(oo_.exo_simul));
             end
             oo_=make_y_(M_,options_,oo_);
-        end;
+        end
         %exo_init
         oo_.exo_simul = exo_init;
         oo_.endo_simul(:,1) = initial_conditions;
@@ -668,8 +668,8 @@ else
             else
                 indx_endo(col_count) = constrained_vars(j) + maximum_lag * ny;
                 col_count = col_count + 1;
-            end;
-        end;
+            end
+        end
         
         r = zeros(second_system_size,1);
         
@@ -696,17 +696,17 @@ else
                         else
                             oo_.exo_simul(maximum_lag + 1,j) = old_exo(maximum_lag + 1,j) + alpha * D_exo(col_count);
                             col_count = col_count + 1;
-                        end;
-                    end;
+                        end
+                    end
                     disp(['Divergence in  Newton: reducing the path length alpha=' num2str(alpha) ' result=' num2str(result) ' sum(sum)=' num2str(sum(sum(isfinite(oo_.endo_simul(:,time_index_constraint))))) ' ny * length(time_index_constraint)=' num2str(ny * length(time_index_constraint)) ' oo_.deterministic_simulation.status=' num2str(oo_.deterministic_simulation.status)]);
                     oo_.endo_simul = [initial_conditions repmat(oo_.steady_state, 1, options_cond_fcst.periods + 1)];
                 else
                     not_achieved = 0;
-                end;
-            end;
+                end
+            end
             if t==constrained_periods
                 ycc = oo_.endo_simul;
-            end;
+            end
             yc = oo_.endo_simul(:,maximum_lag + 1);
             ys = oo_.endo_simul(indx_endo);
             
@@ -720,7 +720,7 @@ else
                     y = yc(constrained_vars(j));
                     r(col_count) = y - constrained_paths(j,t);
                     col_count = col_count + 1;
-                end;
+                end
             end
             
             disp('computation of derivatives w.r. to exogenous shocks');
@@ -745,7 +745,7 @@ else
                     else
                         data1 = M_;
                         Size = 1;
-                    end;
+                    end
                     data1 = M_;
                     if (options_.bytecode)
                         [chck, zz, data1]= bytecode('dynamic','evaluate', z, zx, M_.params, oo_.steady_state, k, data1);
@@ -754,16 +754,16 @@ else
                         data1.g1_x = g1b(:,end - M_.exo_nbr + 1:end);
                         data1.g1 = g1b(:,1 : end - M_.exo_nbr);
                         chck = 0;
-                    end;
+                    end
                     mexErrCheck('bytecode', chck);
-                end;
+                end
                 if k == 1 
                     g1(1:M_.endo_nbr,-M_.endo_nbr + [cur_indx lead_indx]) = data1.g1(:,M_.nspred + 1:end);
                 elseif k == per
                     g1(M_.endo_nbr * (k - 1) + 1 :M_.endo_nbr * k,M_.endo_nbr * (k -2) + [lag_indx cur_indx]) = data1.g1(:,1:M_.nspred + M_.endo_nbr);
                 else
                     g1(M_.endo_nbr * (k - 1) + 1 :M_.endo_nbr * k, M_.endo_nbr * (k -2) + [lag_indx cur_indx lead_indx]) = data1.g1;
-                end;
+                end
                 
                 l2 = 1;
                 pf_c = 1;
@@ -779,21 +779,21 @@ else
                                     for ii = 2:constrained_periods - t + 1
                                         indx_x(l2) = length(controlled_varexo) + pf * (ii - 2) + constraint_index{k + ii - 1}(pf_c);
                                         l2 = l2 + 1;
-                                    end;
+                                    end
                                     pf_c = pf_c + 1;
                                 else
                                     indx_x(l2) = l;
                                     l2 = l2 + 1;
-                                end;
+                                end
                                 cum_index_d_y_x = [cum_index_d_y_x; constrained_vars_t(l)];
                             else
                                 cum_index_d_y_x = [cum_index_d_y_x; constrained_vars_t(l) + (k - 1) * M_.endo_nbr];
                             end
                             cum_l1 = cum_l1 + length(l1);
-                        end;
-                    end;
-                end;
-            end;
+                        end
+                    end
+                end
+            end
             
             d_y_x = - g1 \ g1_x;
 
@@ -819,7 +819,7 @@ else
                     count_col = count_col + 1;
                 end
                 cum_l1 = cum_l1 + length(constrained_vars_t(j1));
-            end;
+            end
 
             
 %             % Numerical computation of the derivatives in the second systme        
@@ -835,7 +835,7 @@ else
 %                         J1(:,col_count) = (oo_.endo_simul(indx_endo) - ys) / eps1;
 %                         oo_.exo_simul(time,j_pos) = saved;
 %                         col_count = col_count + 1;
-%                     end;
+%                     end
 %                 else
 %                     saved = oo_.exo_simul(maximum_lag+1,j_pos);
 %                     oo_.exo_simul(maximum_lag+1,j_pos) = oo_.exo_simul(maximum_lag+1,j_pos) + eps1;
@@ -845,8 +845,8 @@ else
 % %                    J(:,col_count) = (oo_.endo_simul((pp - 1) * M_.endo_nbr + 1: pp * M_.endo_nbr) - ys) / eps1;
 %                     oo_.exo_simul(maximum_lag+1,j_pos) = saved;
 %                     col_count = col_count + 1;
-%                 end;
-%             end;
+%                 end
+%             end
 %             disp('J1');
 %             disp(full(J1));
 %             sdfmlk;
@@ -870,7 +870,7 @@ else
                     z_root = find(abs(ev) < 1e-4);
                     z_root
                     disp(V(:,z_root));
-                end;
+                end
                 old_exo = oo_.exo_simul;
                 col_count = 1;
                 for j = constraint_index_t
@@ -881,14 +881,14 @@ else
                     else
                         oo_.exo_simul(maximum_lag + 1,j_pos) = oo_.exo_simul(maximum_lag + 1,j_pos) + D_exo(col_count);
                         col_count = col_count + 1;
-                    end;
-                end;
-            end;
+                    end
+                end
+            end
             it = it + 1;
-        end;
+        end
         if ~convg
             error(['convergence not achived at time ' int2str(t) ' after ' int2str(it) ' iterations']);
-        end;
+        end
         for j = constraint_index_t
             j_pos=controlled_varexo(j);
             if constrained_perfect_foresight(j)
@@ -900,20 +900,20 @@ else
                 end
             else
                 exo(maximum_lag + t,j_pos) = oo_.exo_simul(maximum_lag + 1,j_pos);
-            end;
-        end;
+            end
+        end
         past_val = past_val + length(time_index_constraint);
         if t < constrained_periods
             endo(maximum_lag + t,:) = yc;
         else
             endo(maximum_lag + t :maximum_lag + options_cond_fcst.periods ,:) = ycc(:,maximum_lag + 1:maximum_lag + options_cond_fcst.periods - constrained_periods + 1)';
-        end;
+        end
         initial_conditions = yc;
         if maximum_lag > 0
             exo_init(1,:) = exo(maximum_lag + t,:);
-        end;
-    end;
-end;
+        end
+    end
+end
 options_.periods = save_options_periods;
 options_.dynatol.f = save_options_dynatol_f;
 options_.initval_file = save_options_initval_file;
@@ -922,4 +922,4 @@ oo_.endo_simul = endo';
 oo_.exo_simul = exo;
 if direct_mode
     data_set = dseries([endo(2:end,1:M_.orig_endo_nbr) exo(2:end,:)], total_periods(1), {plan.endo_names{:} plan.exo_names{:}}, {plan.endo_names{:} plan.exo_names{:}});
-end;
+end
diff --git a/matlab/perfect-foresight-models/solve_stacked_problem.m b/matlab/perfect-foresight-models/solve_stacked_problem.m
index 7a1835ba6..66fa99ffe 100644
--- a/matlab/perfect-foresight-models/solve_stacked_problem.m
+++ b/matlab/perfect-foresight-models/solve_stacked_problem.m
@@ -1,4 +1,4 @@
-function [endogenousvariables, info] = solve_stacked_problem(endogenousvariables, exogenousvariables, steadystate, M, options);
+function [endogenousvariables, info] = solve_stacked_problem(endogenousvariables, exogenousvariables, steadystate, M, options)
 % [endogenousvariables, info] = solve_stacked_problem(endogenousvariables, exogenousvariables, steadystate, M, options);
 % Solves the perfect foresight model using dynare_solve
 %
diff --git a/matlab/plot_identification.m b/matlab/plot_identification.m
index f699d2e42..116909bb2 100644
--- a/matlab/plot_identification.m
+++ b/matlab/plot_identification.m
@@ -58,7 +58,7 @@ siLREnorm = idelre.siLREnorm;
 % end
 tittxt1=regexprep(tittxt, ' ', '_');
 tittxt1=strrep(tittxt1, '.', '');
-if SampleSize == 1,
+if SampleSize == 1
     siJ = idemoments.siJ;
     hh = dyn_figure(options_.nodisplay,'Name',[tittxt, ' - Identification using info from observables']);
     subplot(211)
@@ -72,7 +72,7 @@ if SampleSize == 1,
     set(gca,'xlim',[0 nparam+1])
     set(gca,'xticklabel','')
     dy = get(gca,'ylim');
-    for ip=1:nparam,
+    for ip=1:nparam
         text(ip,dy(1),name{is(ip)},'rotation',90,'HorizontalAlignment','right','interpreter','none')
     end
     if ~all(isnan(idehess.ide_strength_J_prior))
@@ -80,7 +80,7 @@ if SampleSize == 1,
     else
         legend('relative to param value','Location','Best')
     end
-    if  idehess.flag_score,
+    if  idehess.flag_score
         title('Identification strength with asymptotic Information matrix (log-scale)')
     else
         title('Identification strength with moments Information matrix (log-scale)')
@@ -96,7 +96,7 @@ if SampleSize == 1,
     set(gca,'xlim',[0 nparam+1])
     set(gca,'xticklabel','')
     dy = get(gca,'ylim');
-    for ip=1:nparam,
+    for ip=1:nparam
         text(ip,dy(1),name{is(ip)},'rotation',90,'HorizontalAlignment','right','interpreter','none')
     end
     if ~all(isnan(idehess.deltaM_prior))
@@ -104,7 +104,7 @@ if SampleSize == 1,
     else
         legend('relative to param value','Location','Best')
     end
-    if  idehess.flag_score,
+    if  idehess.flag_score
         title('Sensitivity component with asymptotic Information matrix (log-scale)')
     else
         title('Sensitivity component with moments Information matrix (log-scale)')
@@ -124,8 +124,8 @@ if SampleSize == 1,
     end
     dyn_saveas(hh,[IdentifDirectoryName '/' M_.fname '_ident_strength_' tittxt1],options_.nodisplay,options_.graph_format);
     
-    if advanced,
-        if ~options_.nodisplay,
+    if advanced
+        if ~options_.nodisplay
             skipline()
             disp('Press ENTER to plot advanced diagnostics'), pause(5),
         end
@@ -146,7 +146,7 @@ if SampleSize == 1,
             set(gca,'xlim',[0 nparam+1])
             set(gca,'xticklabel','')
             dy = get(gca,'ylim');
-            for ip=1:nparam,
+            for ip=1:nparam
                 text(ip,dy(1),name{is(ip)},'rotation',90,'HorizontalAlignment','right','interpreter','none')
             end
             legend('Moments','Model','LRE model','Location','Best')
@@ -167,16 +167,16 @@ if SampleSize == 1,
             end
         end
         % identificaton patterns
-        for  j=1:size(idemoments.cosnJ,2),
+        for  j=1:size(idemoments.cosnJ,2)
             pax=NaN(nparam,nparam);
 %             fprintf('\n')
 %             disp(['Collinearity patterns with ', int2str(j) ,' parameter(s)'])
 %             fprintf('%-15s [%-*s] %10s\n','Parameter',(15+1)*j,' Expl. params ','cosn')
-            for i=1:nparam,
+            for i=1:nparam
                 namx='';
-                for in=1:j,
+                for in=1:j
                     dumpindx = idemoments.pars{i,j}(in);
-                    if isnan(dumpindx),
+                    if isnan(dumpindx)
                         namx=[namx ' ' sprintf('%-15s','--')];
                     else
                         namx=[namx ' ' sprintf('%-15s',name{dumpindx})];
@@ -189,7 +189,7 @@ if SampleSize == 1,
             imagesc(pax,[0 1]);
             set(gca,'xticklabel','')
             set(gca,'yticklabel','')
-            for ip=1:nparam,
+            for ip=1:nparam
                 text(ip,(0.5),name{ip},'rotation',90,'HorizontalAlignment','left','interpreter','none')
                 text(0.5,ip,name{ip},'rotation',0,'HorizontalAlignment','right','interpreter','none')
             end
@@ -198,7 +198,7 @@ if SampleSize == 1,
             ax=colormap;
             ax(1,:)=[0.9 0.9 0.9];
             colormap(ax);
-            if nparam>10,
+            if nparam>10
                 set(gca,'xtick',(5:5:nparam))
                 set(gca,'ytick',(5:5:nparam))
             end
@@ -223,8 +223,8 @@ if SampleSize == 1,
         skipline()
         [U,S,V]=svd(idehess.AHess,0);
         S=diag(S);
-        if idehess.flag_score,
-            if nparam<5,
+        if idehess.flag_score
+            if nparam<5
                 f1 = dyn_figure(options_.nodisplay,'Name',[tittxt,' - Identification patterns (Information matrix)']);
                 tex_tit_1=[tittxt,' - Identification patterns (Information matrix)'];
             else
@@ -236,7 +236,7 @@ if SampleSize == 1,
         else
 %             S = idemoments.S;
 %             V = idemoments.V;
-            if nparam<5,
+            if nparam<5
                 f1 = dyn_figure(options_.nodisplay,'Name',[tittxt,' - Identification patterns (moments Information matrix)']);
                 tex_tit_1=[tittxt,' - Identification patterns (moments Information matrix)'];
             else
@@ -246,25 +246,25 @@ if SampleSize == 1,
                 tex_tit_2=[tittxt,' - Identification patterns (moments Information matrix): HIGHEST SV'];
             end
         end
-        for j=1:min(nparam,8),
-            if j<5,
+        for j=1:min(nparam,8)
+            if j<5
                 set(0,'CurrentFigure',f1),
                 jj=j;
             else
                 set(0,'CurrentFigure',f2),
                 jj=j-4;
             end
-            subplot(4,1,jj),
+            subplot(4,1,jj)
             if j<5
-                bar(abs(V(:,end-j+1))),
+                bar(abs(V(:,end-j+1)))
                 Stit = S(end-j+1);
             else
                 bar(abs(V(:,jj))),
                 Stit = S(jj);
             end
             set(gca,'xticklabel','')
-            if j==4 || j==nparam || j==8,
-                for ip=1:nparam,
+            if j==4 || j==nparam || j==8
+                for ip=1:nparam
                     text(ip,-0.02,name{ip},'rotation',90,'HorizontalAlignment','right','interpreter','none')
                 end
             end
@@ -284,7 +284,7 @@ if SampleSize == 1,
             fprintf(fidTeX,'%% End Of TeX file. \n');
             fclose(fidTeX);
         end
-        if nparam>4,
+        if nparam>4
             dyn_saveas(f2,[  IdentifDirectoryName '/' M_.fname '_ident_pattern_' tittxt1 '_2' ],options_.nodisplay,options_.graph_format);
             if options_.TeX && any(strcmp('eps',cellstr(options_.graph_format)))
                 fidTeX = fopen([  IdentifDirectoryName '/' M_.fname '_ident_pattern_' tittxt1 '_2.tex'],'w');
@@ -309,7 +309,7 @@ else
     [ss, is] = sort(mmm);
     mmm = mean(siJnorm)';
     mmm = mmm./max(mmm);
-    if advanced,
+    if advanced
         mmm1 = mean(siHnorm)';
         mmm=[mmm mmm1./max(mmm1)];
         mmm1 = mean(siLREnorm)';
@@ -322,10 +322,10 @@ else
     set(gca,'xlim',[0 nparam+1])
     set(gca,'xticklabel','')
     dy = get(gca,'ylim');
-    for ip=1:nparam,
+    for ip=1:nparam
         text(ip,dy(1),name{is(ip)},'rotation',90,'HorizontalAlignment','right','interpreter','none')
     end
-    if advanced,
+    if advanced
         legend('Moments','Model','LRE model','Location','Best')
     end
     title('MC mean of sensitivity measures')
@@ -344,7 +344,7 @@ else
         fclose(fidTeX);
     end
     
-    if advanced,
+    if advanced
         if ~options_.nodisplay,
             skipline()
             disp('Press ENTER to display advanced diagnostics'), pause(5),
@@ -397,7 +397,7 @@ else
 %             [proba, dproba] = stab_map_1(params, is(1:ncut), is(ncut+1:end), ['MC_HighestMultiCollinearity_',name{j}], 1, [], IdentifDirectoryName, 0.15);
 %         end
 
-        if nparam<5,
+        if nparam<5
             f1 = dyn_figure(options_.nodisplay,'Name',[tittxt,' - MC Identification patterns (moments): HIGHEST SV']);
             tex_tit_1=[tittxt,' - MC Identification patterns (moments): HIGHEST SV'];
         else
@@ -407,13 +407,13 @@ else
             tex_tit_2=[tittxt,' - MC Identification patterns (moments): HIGHEST SV'];
         end
         nplots=min(nparam,8);
-        if nplots>4,
+        if nplots>4
             nsubplo=ceil(nplots/2);
         else
             nsubplo=nplots;
         end
-        for j=1:nplots,
-            if (nparam>4 && j<=ceil(nplots/2)) || nparam<5,
+        for j=1:nplots
+            if (nparam>4 && j<=ceil(nplots/2)) || nparam<5
                 set(0,'CurrentFigure',f1),
                 jj=j;
                 VVV=squeeze(abs(idemoments.V(:,:,end-j+1)));
@@ -424,8 +424,8 @@ else
                 VVV=squeeze(abs(idemoments.V(:,:,jj)));
                 SSS = idemoments.S(:,jj);
             end
-            subplot(nsubplo,1,jj),
-            for i=1:nparam,
+            subplot(nsubplo,1,jj)
+            for i=1:nparam
                 [post_mean, post_median(:,i), post_var, hpd_interval(i,:), post_deciles] = posterior_moments(VVV(:,i),0,0.9);
             end
             bar(post_median)
@@ -433,8 +433,8 @@ else
             Stit=mean(SSS);
 
             set(gca,'xticklabel','')
-            if j==4 || j==nparam || j==8,
-                for ip=1:nparam,
+            if j==4 || j==nparam || j==8
+                for ip=1:nparam
                     text(ip,-0.02,name{ip},'rotation',90,'HorizontalAlignment','right','interpreter','none')
                 end
             end
@@ -454,7 +454,7 @@ else
             fprintf(fidTeX,'%% End Of TeX file. \n');
             fclose(fidTeX);
         end
-        if nparam>4,
+        if nparam>4
             dyn_saveas(f2,[  IdentifDirectoryName '/' M_.fname '_MC_ident_pattern_2' ],options_.nodisplay,options_.graph_format);
             if options_.TeX && any(strcmp('eps',cellstr(options_.graph_format)))
                 fidTeX = fopen([  IdentifDirectoryName '/' M_.fname '_MC_ident_pattern_2.tex'],'w');
diff --git a/matlab/plot_priors.m b/matlab/plot_priors.m
index 04f371566..2b2fc83f6 100644
--- a/matlab/plot_priors.m
+++ b/matlab/plot_priors.m
@@ -42,7 +42,7 @@ if TeX && any(strcmp('eps',cellstr(options_.graph_format)))
     fprintf(fidTeX,['%% ' datestr(now,0) '\n']);
     fprintf(fidTeX,' \n');
 end
-for plt = 1:nbplt,
+for plt = 1:nbplt
     hplt = dyn_figure(options_.nodisplay,'Name',figurename);
     if TeX
         TeXNAMES = [];
@@ -73,7 +73,7 @@ for plt = 1:nbplt,
     dyn_saveas(hplt,[M_.fname '_Priors' int2str(plt)],options_.nodisplay,options_.graph_format);
     if TeX && any(strcmp('eps',cellstr(options_.graph_format)))
         fprintf(fidTeX,'\\begin{figure}[H]\n');
-        for jj = 1:nstar0,
+        for jj = 1:nstar0
             fprintf(fidTeX,'\\psfrag{%s}[1][][0.5][0]{%s}\n',deblank(NAMES(jj,:)),deblank(TeXNAMES(jj,:)));
         end
         fprintf(fidTeX,'\\centering\n');
diff --git a/matlab/plot_shock_decomposition.m b/matlab/plot_shock_decomposition.m
index 698192a91..b7d3675fc 100644
--- a/matlab/plot_shock_decomposition.m
+++ b/matlab/plot_shock_decomposition.m
@@ -55,7 +55,7 @@ fig_name='';
 % steadystate=0;
 % write_xls=0;
 
-if isfield(options_.plot_shock_decomp,'expand'), % private trap for uimenu calls
+if isfield(options_.plot_shock_decomp,'expand') % private trap for uimenu calls
     expand=options_.plot_shock_decomp.expand;
 else
     expand=0;
@@ -72,15 +72,15 @@ forecast_ = options_.shock_decomp.forecast;
 steadystate = options_.plot_shock_decomp.steadystate;
 write_xls = options_.plot_shock_decomp.write_xls;
 
-if vintage_,
+if vintage_
     forecast_ = min(forecast_,options_.nobs-vintage_);
 end
 
 initial_date = options_.initial_date;
  
-if isfield(options_.plot_shock_decomp,'q2a'), % private trap for aoa calls
+if isfield(options_.plot_shock_decomp,'q2a') % private trap for aoa calls
     q2a=options_.plot_shock_decomp.q2a;
-    if isstruct(q2a) && isempty(fieldnames(q2a)),
+    if isstruct(q2a) && isempty(fieldnames(q2a))
         q2a=0;
     end
 else
@@ -126,12 +126,12 @@ end
 steady_state = oo_.steady_state;
 
 if isequal(type,'aoa') && isstruct(q2a) && realtime_
-        if isempty(initial_date),
+        if isempty(initial_date)
             t0=1;
             initial_date = dates('1Y');
         else
             initial_date0 = dates([int2str(initial_date.time(1)) 'Y']);
-            if initial_date.time(2)==1,
+            if initial_date.time(2)==1
                 t0=1;
                 initial_date1=initial_date0;
             else
@@ -142,22 +142,22 @@ if isequal(type,'aoa') && isstruct(q2a) && realtime_
         t0=min(options_.plot_shock_decomp.save_realtime);
         ini1 = initial_date+t0-1;
         t0=t0+(4-ini1.time(2));
-    if ~isfield(q2a,'var_type'), % private trap for aoa calls
+    if ~isfield(q2a,'var_type') % private trap for aoa calls
         q2a.var_type=1;
     end
-    if ~isfield(q2a,'islog'), % private trap for aoa calls
+    if ~isfield(q2a,'islog') % private trap for aoa calls
         q2a.islog=0;
     end
-    if ~isfield(q2a,'GYTREND0'), % private trap for aoa calls
+    if ~isfield(q2a,'GYTREND0') % private trap for aoa calls
         q2a.GYTREND0=0;
     end
-    if ~isfield(q2a,'aux'), % private trap for aoa calls
+    if ~isfield(q2a,'aux') % private trap for aoa calls
         q2a.aux=0;
     end
-    if ~isfield(q2a,'cumfix'), % private trap for aoa calls
+    if ~isfield(q2a,'cumfix') % private trap for aoa calls
         q2a.cumfix=1;
     end
-    if ~isfield(q2a,'plot'), % private trap for aoa calls
+    if ~isfield(q2a,'plot') % private trap for aoa calls
         q2a.plot=1; % growth rate
     end
     
@@ -189,7 +189,7 @@ if options_.plot_shock_decomp.use_shock_groups
     ngroups = length(shock_ind);
     fig_name=[fig_name ' group ' options_.plot_shock_decomp.use_shock_groups];
     shock_names = shock_ind;
-    for i=1:ngroups,
+    for i=1:ngroups
        shock_names{i} = (shock_groups.(shock_ind{i}).label);
     end
     zz = zeros(endo_nbr,ngroups+2,gend);
@@ -206,7 +206,7 @@ if options_.plot_shock_decomp.use_shock_groups
     shock_groups.(['group' int2str(ngroups+1)]).label =  'Others';
     shock_groups.(['group' int2str(ngroups+1)]).shocks =  cellstr(M_.exo_names(find(~ismember([1:M_.exo_nbr],kcum)),:))';
     M_.shock_groups.(options_.plot_shock_decomp.use_shock_groups)=shock_groups;
-    if any(any(zothers)),
+    if any(any(zothers))
         shock_names = [shock_names; {'Others + Initial Values'}];
     end        
     zz(:,ngroups+1,:) = sum(z(:,1:nshocks+1,:),2);
@@ -222,7 +222,7 @@ end
         MAP(end,:) = [0.7 0.7 0.7];
 %         MAP = [MAP; [0.7 0.7 0.7]; [0.3 0.3 0.3]];
 
-if isempty(options_.plot_shock_decomp.colormap),
+if isempty(options_.plot_shock_decomp.colormap)
     options_.plot_shock_decomp.colormap = MAP;
 end
 
@@ -243,12 +243,12 @@ switch type
         
     case 'aoa'
 
-        if isempty(initial_date),
+        if isempty(initial_date)
             t0=4;
             initial_date = dates('1Y');
         else
             initial_date0 = dates([int2str(initial_date.time(1)) 'Y']);
-            if initial_date.time(2)==1,
+            if initial_date.time(2)==1
                 t0=1;
                 initial_date1=initial_date0;
             else
@@ -258,22 +258,22 @@ switch type
         end
         if isstruct(q2a) 
             if realtime_ == 0
-            if ~isfield(q2a,'var_type'), % private trap for aoa calls
+            if ~isfield(q2a,'var_type') % private trap for aoa calls
                 q2a.var_type=1;
             end
-            if ~isfield(q2a,'islog'), % private trap for aoa calls
+            if ~isfield(q2a,'islog') % private trap for aoa calls
                 q2a.islog=0;
             end
-            if ~isfield(q2a,'GYTREND0'), % private trap for aoa calls
+            if ~isfield(q2a,'GYTREND0') % private trap for aoa calls
                 q2a.GYTREND0=0;
             end
-            if ~isfield(q2a,'aux'), % private trap for aoa calls
+            if ~isfield(q2a,'aux') % private trap for aoa calls
                 q2a.aux=0;
             end
-            if ~isfield(q2a,'cumfix'), % private trap for aoa calls
+            if ~isfield(q2a,'cumfix') % private trap for aoa calls
                 q2a.cumfix=1;
             end
-            if ~isfield(q2a,'plot'), % private trap for aoa calls
+            if ~isfield(q2a,'plot') % private trap for aoa calls
                 q2a.plot=1; % growth rate
             end
             
@@ -341,7 +341,7 @@ z = z(:,:,a:b);
 
 options_.plot_shock_decomp.fig_name=fig_name;
 options_.plot_shock_decomp.orig_varlist = varlist;
-if detail_plot,
+if detail_plot
     graph_decomp_detail(z,shock_names,M_.endo_names,i_var,my_initial_date,M_,options_)
 else
     graph_decomp(z,shock_names,M_.endo_names,i_var,my_initial_date,M_,options_);
diff --git a/matlab/pm3.m b/matlab/pm3.m
index ae0f474d1..2417f8c05 100644
--- a/matlab/pm3.m
+++ b/matlab/pm3.m
@@ -60,7 +60,7 @@ else
     end
 end
 if options_.TeX
-    if isempty(tit_tex),
+    if isempty(tit_tex)
         tit_tex=names1;
     end
         
@@ -321,13 +321,13 @@ nvar0=nvar;
 
 if ~isoctave
     % Commenting for testing!
-    if isnumeric(options_.parallel) || ceil(size(varlist,1)/MaxNumberOfPlotsPerFigure)<4,
+    if isnumeric(options_.parallel) || ceil(size(varlist,1)/MaxNumberOfPlotsPerFigure)<4
         fout = pm3_core(localVars,1,nvar,0);
         
         % Parallel execution!
     else
         isRemoteOctave = 0;
-        for indPC=1:length(options_.parallel),
+        for indPC=1:length(options_.parallel)
             isRemoteOctave = isRemoteOctave + (findstr(options_.parallel(indPC).MatlabOctavePath, 'octave'));
         end
         if isRemoteOctave
@@ -356,12 +356,12 @@ if options_.TeX && any(strcmp('eps',cellstr(options_.graph_format)))
     nvar0=cumsum(nvar0);
 
     i=0;    
-    for j=1:length(nvar0),
+    for j=1:length(
     
     NAMES = [];
     TEXNAMES = [];
     nvar=nvar0(j);
-    while i<nvar,
+    while i<nvar
         i=i+1;
         if max(abs(Mean(:,i))) > 10^(-6)
             subplotnum = subplotnum+1;
diff --git a/matlab/pm3_core.m b/matlab/pm3_core.m
index 32052f83c..e484304a8 100644
--- a/matlab/pm3_core.m
+++ b/matlab/pm3_core.m
@@ -30,7 +30,7 @@ function myoutput=pm3_core(myinputs,fpar,nvar,whoiam, ThisMatlab)
 % You should have received a copy of the GNU General Public License
 % along with Dynare.  If not, see <http://www.gnu.org/licenses/>.
 
-if nargin<4,
+if nargin<4
     whoiam=0;
 end
 
@@ -66,7 +66,7 @@ figunumber = 0;
 subplotnum = 0;
 hh = dyn_figure(options_.nodisplay,'Name',[tit1 ' ' int2str(figunumber+1)]);
 RemoteFlag = 0;
-if whoiam,
+if whoiam
     if Parallel(ThisMatlab).Local ==0
         RemoteFlag=1;
     end
@@ -101,7 +101,7 @@ for i=fpar:nvar
         end
     end
     
-    if whoiam,
+    if whoiam
         if Parallel(ThisMatlab).Local==0
             DirectoryName = CheckPath('Output',M_.dname);
         end
@@ -109,7 +109,7 @@ for i=fpar:nvar
     
     if subplotnum == MaxNumberOfPlotsPerFigure || i == nvar
         dyn_saveas(hh,[M_.dname '/Output/'  M_.fname '_' name3 '_' deblank(tit3(i,:))],options_.nodisplay,options_.graph_format);
-        if RemoteFlag==1,
+        if RemoteFlag==1
             OutputFileName = [OutputFileName; {[M_.dname, filesep, 'Output',filesep], [M_.fname '_' name3 '_' deblank(tit3(i,:)) '.*']}];
         end
         subplotnum = 0;
@@ -119,7 +119,7 @@ for i=fpar:nvar
         end
     end
     
-    if whoiam,
+    if whoiam
 %         waitbarString = [ 'Variable ' int2str(i) '/' int2str(nvar) ' done.'];
 %         fMessageStatus((i-fpar+1)/(nvar-fpar+1),whoiam,waitbarString, waitbarTitle, Parallel(ThisMatlab));
         dyn_waitbar((i-fpar+1)/(nvar-fpar+1),h);
@@ -128,7 +128,7 @@ for i=fpar:nvar
     
 end
 
-if whoiam,
+if whoiam
     dyn_waitbar_close(h);
 end
 myoutput.OutputFileName=OutputFileName;
diff --git a/matlab/posterior_sampler.m b/matlab/posterior_sampler.m
index be512d140..5afed9575 100644
--- a/matlab/posterior_sampler.m
+++ b/matlab/posterior_sampler.m
@@ -107,7 +107,7 @@ localVars =   struct('TargetFun', TargetFun, ...
                      'oo_', oo_,...
                      'varargin',[]);
 
-if strcmp(sampler_options.posterior_sampling_method,'tailored_random_block_metropolis_hastings');
+if strcmp(sampler_options.posterior_sampling_method,'tailored_random_block_metropolis_hastings')
     localVars.options_.silent_optimizer=1; %locally set optimizer to silent mode
     if ~isempty(sampler_options.optim_opt)
         localVars.options_.optim_opt=sampler_options.optim_opt; %locally set options for optimizer
@@ -117,7 +117,7 @@ end
 % User doesn't want to use parallel computing, or wants to compute a
 % single chain compute sequentially.
 
-if isnumeric(options_.parallel) || (nblck-fblck)==0,
+if isnumeric(options_.parallel) || (nblck-fblck)==0
     fout = posterior_sampler_core(localVars, fblck, nblck, 0);
     record = fout.record;
     % Parallel in Local or remote machine.   
@@ -128,20 +128,20 @@ else
     NamFileInput(1,:) = {'',[ModelName '_static.m']};
     NamFileInput(2,:) = {'',[ModelName '_dynamic.m']};
     NamFileInput(3,:) = {'',[M_.fname '_set_auxiliary_variables.m']};
-    if options_.steadystate_flag,
-        if options_.steadystate_flag == 1,
+    if options_.steadystate_flag
+        if options_.steadystate_flag == 1
             NamFileInput(length(NamFileInput)+1,:)={'',[M_.fname '_steadystate.m']};
         else
             NamFileInput(length(NamFileInput)+1,:)={'',[M_.fname '_steadystate2.m']};
         end
     end
-    if (options_.load_mh_file~=0)  && any(fline>1) ,
+    if (options_.load_mh_file~=0)  && any(fline>1)
         NamFileInput(length(NamFileInput)+1,:)={[M_.dname '/metropolis/'],[ModelName '_mh' int2str(NewFile(1)) '_blck*.mat']};
     end
     % from where to get back results
     %     NamFileOutput(1,:) = {[M_.dname,'/metropolis/'],'*.*'};
     [fout, nBlockPerCPU, totCPU] = masterParallel(options_.parallel, fblck, nblck,NamFileInput,'posterior_sampler_core', localVars, globalVars, options_.parallel_info);
-    for j=1:totCPU,
+    for j=1:totCPU
         offset = sum(nBlockPerCPU(1:j-1))+fblck-1;
         record.LastLogPost(offset+1:sum(nBlockPerCPU(1:j)))=fout(j).record.LastLogPost(offset+1:sum(nBlockPerCPU(1:j)));
         record.LastParameters(offset+1:sum(nBlockPerCPU(1:j)),:)=fout(j).record.LastParameters(offset+1:sum(nBlockPerCPU(1:j)),:);
diff --git a/matlab/posterior_sampler_core.m b/matlab/posterior_sampler_core.m
index d88ae742a..125cb872d 100644
--- a/matlab/posterior_sampler_core.m
+++ b/matlab/posterior_sampler_core.m
@@ -53,7 +53,7 @@ function myoutput = posterior_sampler_core(myinputs,fblck,nblck,whoiam, ThisMatl
 % You should have received a copy of the GNU General Public License
 % along with Dynare.  If not, see <http://www.gnu.org/licenses/>.
 
-if nargin<4,
+if nargin<4
     whoiam=0;
 end
 
@@ -108,7 +108,7 @@ end
 %
 
 sampler_options.xparam1 = xparam1;
-if ~isempty(d),
+if ~isempty(d)
     sampler_options.proposal_covariance_Cholesky_decomposition = d*diag(bayestopt_.jscale);
     %store information for load_mh_file
     record.ProposalCovariance=d;
@@ -117,7 +117,7 @@ end
 
 block_iter=0;
 
-for curr_block = fblck:nblck,
+for curr_block = fblck:nblck
     LastSeeds=[];
     block_iter=block_iter+1;
     try
@@ -192,7 +192,7 @@ for curr_block = fblck:nblck,
         end
         if (draw_index_current_file == InitSizeArray(curr_block)) || (draw_iter == nruns(curr_block)) % Now I save the simulations, either because the current file is full or the chain is done
             [LastSeeds.(['file' int2str(NewFile(curr_block))]).Unifor, LastSeeds.(['file' int2str(NewFile(curr_block))]).Normal] = get_dynare_random_generator_state();
-            if save_tmp_file,
+            if save_tmp_file
                 delete([BaseName '_mh_tmp_blck' int2str(curr_block) '.mat']);
             end
             save([BaseName '_mh' int2str(NewFile(curr_block)) '_blck' int2str(curr_block) '.mat'],'x2','logpo2','LastSeeds');
diff --git a/matlab/posterior_sampler_initialization.m b/matlab/posterior_sampler_initialization.m
index f7927a173..7d84bed96 100644
--- a/matlab/posterior_sampler_initialization.m
+++ b/matlab/posterior_sampler_initialization.m
@@ -112,7 +112,7 @@ if ~options_.load_mh_file && ~options_.mh_recover
     fprintf(fidlog,['  Number of blocks...............: ' int2str(NumberOfBlocks) '\n']);
     fprintf(fidlog,['  Number of simulations per block: ' int2str(nruns(1)) '\n']);
     fprintf(fidlog,' \n');
-    if isempty(d),
+    if isempty(d)
         prior_draw(bayestopt_,options_.prior_trunc);
     end
     % Find initial values for the NumberOfBlocks chains...
@@ -127,7 +127,7 @@ if ~options_.load_mh_file && ~options_.mh_recover
             init_iter   = 0;
             trial = 1;
             while validate == 0 && trial <= 10
-                if isempty(d),
+                if isempty(d)
                     candidate = prior_draw();
                 else
                     candidate = rand_multivariate_normal( transpose(xparam1), d * options_.mh_init_scale, npar);
@@ -234,7 +234,7 @@ if ~options_.load_mh_file && ~options_.mh_recover
     fprintf(fidlog,['    Expected number of files per block.......: ' int2str(AnticipatedNumberOfFiles) '.\n']);
     fprintf(fidlog,['    Expected number of lines in the last file: ' int2str(AnticipatedNumberOfLinesInTheLastFile) '.\n']);
     fprintf(fidlog,['\n']);
-    for j = 1:NumberOfBlocks,
+    for j = 1:NumberOfBlocks
         fprintf(fidlog,['    Initial state of the Gaussian random number generator for chain number ',int2str(j),':\n']);
         for i=1:length(record.InitialSeeds(j).Normal)
             fprintf(fidlog,['      ' num2str(record.InitialSeeds(j).Normal(i)') '\n']);
@@ -243,7 +243,7 @@ if ~options_.load_mh_file && ~options_.mh_recover
         for i=1:length(record.InitialSeeds(j).Unifor)
             fprintf(fidlog,['      ' num2str(record.InitialSeeds(j).Unifor(i)') '\n']);
         end
-    end,
+    end
     fprintf(fidlog,' \n');
     fclose(fidlog);
 elseif options_.load_mh_file && ~options_.mh_recover
diff --git a/matlab/prior_draw.m b/matlab/prior_draw.m
index 4eb628df9..5beea3f7d 100644
--- a/matlab/prior_draw.m
+++ b/matlab/prior_draw.m
@@ -110,7 +110,7 @@ end
 if uniform_draws
     pdraw(uniform_index) = rand(length(uniform_index),1).*(p4(uniform_index)-p3(uniform_index)) + p3(uniform_index);  
     out_of_bound = find( (pdraw(uniform_index)'>ub(uniform_index)) | (pdraw(uniform_index)'<lb(uniform_index)));
-    while ~isempty(out_of_bound),
+    while ~isempty(out_of_bound)
         pdraw(uniform_index) = rand(length(uniform_index),1).*(p4(uniform_index)-p3(uniform_index)) + p3(uniform_index);
         out_of_bound = find( (pdraw(uniform_index)'>ub(uniform_index)) | (pdraw(uniform_index)'<lb(uniform_index)));
     end
@@ -119,7 +119,7 @@ end
 if gaussian_draws
     pdraw(gaussian_index) = randn(length(gaussian_index),1).*p7(gaussian_index) + p6(gaussian_index);
     out_of_bound = find( (pdraw(gaussian_index)'>ub(gaussian_index)) | (pdraw(gaussian_index)'<lb(gaussian_index)));
-    while ~isempty(out_of_bound),
+    while ~isempty(out_of_bound)
         pdraw(gaussian_index(out_of_bound)) = randn(length(gaussian_index(out_of_bound)),1).*p7(gaussian_index(out_of_bound)) + p6(gaussian_index(out_of_bound));
         out_of_bound = find( (pdraw(gaussian_index)'>ub(gaussian_index)) | (pdraw(gaussian_index)'<lb(gaussian_index)));
     end
@@ -128,7 +128,7 @@ end
 if gamma_draws
     pdraw(gamma_index) = gamrnd(p6(gamma_index),p7(gamma_index))+p3(gamma_index);
     out_of_bound = find( (pdraw(gamma_index)'>ub(gamma_index)) | (pdraw(gamma_index)'<lb(gamma_index)));
-    while ~isempty(out_of_bound),
+    while ~isempty(out_of_bound)
         pdraw(gamma_index(out_of_bound)) = gamrnd(p6(gamma_index(out_of_bound)),p7(gamma_index(out_of_bound)))+p3(gamma_index(out_of_bound));
         out_of_bound = find( (pdraw(gamma_index)'>ub(gamma_index)) | (pdraw(gamma_index)'<lb(gamma_index)));
     end
@@ -137,7 +137,7 @@ end
 if beta_draws
     pdraw(beta_index) = (p4(beta_index)-p3(beta_index)).*betarnd(p6(beta_index),p7(beta_index))+p3(beta_index);
     out_of_bound = find( (pdraw(beta_index)'>ub(beta_index)) | (pdraw(beta_index)'<lb(beta_index)));
-    while ~isempty(out_of_bound),
+    while ~isempty(out_of_bound)
         pdraw(beta_index(out_of_bound)) = (p4(beta_index(out_of_bound))-p3(beta_index(out_of_bound))).*betarnd(p6(beta_index(out_of_bound)),p7(beta_index(out_of_bound)))+p3(beta_index(out_of_bound));
         out_of_bound = find( (pdraw(beta_index)'>ub(beta_index)) | (pdraw(beta_index)'<lb(beta_index)));
     end
@@ -147,7 +147,7 @@ if inverse_gamma_1_draws
     pdraw(inverse_gamma_1_index) = ...
         sqrt(1./gamrnd(p7(inverse_gamma_1_index)/2,2./p6(inverse_gamma_1_index)))+p3(inverse_gamma_1_index);
     out_of_bound = find( (pdraw(inverse_gamma_1_index)'>ub(inverse_gamma_1_index)) | (pdraw(inverse_gamma_1_index)'<lb(inverse_gamma_1_index)));
-    while ~isempty(out_of_bound),
+    while ~isempty(out_of_bound)
         pdraw(inverse_gamma_1_index(out_of_bound)) = ...
             sqrt(1./gamrnd(p7(inverse_gamma_1_index(out_of_bound))/2,2./p6(inverse_gamma_1_index(out_of_bound))))+p3(inverse_gamma_1_index(out_of_bound));
         out_of_bound = find( (pdraw(inverse_gamma_1_index)'>ub(inverse_gamma_1_index)) | (pdraw(inverse_gamma_1_index)'<lb(inverse_gamma_1_index)));
@@ -158,7 +158,7 @@ if inverse_gamma_2_draws
     pdraw(inverse_gamma_2_index) = ...
         1./gamrnd(p7(inverse_gamma_2_index)/2,2./p6(inverse_gamma_2_index))+p3(inverse_gamma_2_index);
     out_of_bound = find( (pdraw(inverse_gamma_2_index)'>ub(inverse_gamma_2_index)) | (pdraw(inverse_gamma_2_index)'<lb(inverse_gamma_2_index)));
-    while ~isempty(out_of_bound),
+    while ~isempty(out_of_bound)
         pdraw(inverse_gamma_2_index(out_of_bound)) = ...
             1./gamrnd(p7(inverse_gamma_2_index(out_of_bound))/2,2./p6(inverse_gamma_2_index(out_of_bound)))+p3(inverse_gamma_2_index(out_of_bound));
         out_of_bound = find( (pdraw(inverse_gamma_2_index)'>ub(inverse_gamma_2_index)) | (pdraw(inverse_gamma_2_index)'<lb(inverse_gamma_2_index)));
@@ -168,7 +168,7 @@ end
 if weibull_draws
     pdraw(weibull_index) = wblrnd(p7(weibull_index), p6(weibull_index)) + p3(weibull_index);
     out_of_bound = find( (pdraw(weibull_index)'>ub(weibull_index)) | (pdraw(weibull_index)'<lb(weibull_index)));
-    while ~isempty(out_of_bound),
+    while ~isempty(out_of_bound)
         pdraw(weibull_index(out_of_bound)) = wblrnd(p7(weibull_index(out_of_bound)),p6(weibull_index(out_of_bound)))+p3(weibull_index(out_of_bound));
         out_of_bound = find( (pdraw(weibull_index)'>ub(weibull_index)) | (pdraw(weibull_index)'<lb(weibull_index)));
     end
diff --git a/matlab/prior_posterior_statistics.m b/matlab/prior_posterior_statistics.m
index b3cfdc933..e81f8024a 100644
--- a/matlab/prior_posterior_statistics.m
+++ b/matlab/prior_posterior_statistics.m
@@ -79,7 +79,7 @@ elseif strcmpi(type,'gsa')
         DirectoryName = CheckPath(['gsa',filesep,'mc'],M_.dname);
         load([ RootDirectoryName filesep  M_.fname '_mc.mat'],'lpmat0','lpmat','istable')
     end
-    if ~isempty(lpmat0),
+    if ~isempty(lpmat0)
         x=[lpmat0(istable,:) lpmat(istable,:)];
     else
         x=lpmat(istable,:);
@@ -207,7 +207,7 @@ localVars.MAX_momentsno = MAX_momentsno;
 localVars.ifil=ifil;
 localVars.DirectoryName = DirectoryName;
 
-if strcmpi(type,'posterior'),
+if strcmpi(type,'posterior')
     BaseName = [DirectoryName filesep M_.fname];
     load_last_mh_history_file(DirectoryName, M_.fname);
     FirstMhFile = record.KeepedDraws.FirstMhFile;
@@ -217,7 +217,7 @@ if strcmpi(type,'posterior'),
     TotalNumberOfMhDraws = sum(record.MhDraws(:,1));
     NumberOfDraws = TotalNumberOfMhDraws-floor(options_.mh_drop*TotalNumberOfMhDraws);
     mh_nblck = options_.mh_nblck;
-    if B==NumberOfDraws*mh_nblck,
+    if B==NumberOfDraws*mh_nblck
         % we load all retained MH runs !
         logpost=GetAllPosteriorDraws(0, FirstMhFile, FirstLine, TotalNumberOfMhFiles, NumberOfDraws);
         for column=1:npar
@@ -232,18 +232,18 @@ if strcmpi(type,'posterior'),
     localVars.logpost=logpost;
 end
 
-if ~strcmpi(type,'prior'),
+if ~strcmpi(type,'prior')
     localVars.x=x;
 end
 
 % Like sequential execution!
-if isnumeric(options_.parallel),
+if isnumeric(options_.parallel)
     [fout] = prior_posterior_statistics_core(localVars,1,B,0);
     % Parallel execution!
 else
     [nCPU, totCPU, nBlockPerCPU] = distributeJobs(options_.parallel, 1, B);
     ifil=zeros(n_variables_to_fill,totCPU);
-    for j=1:totCPU-1,
+    for j=1:totCPU-1
         if run_smoother
             nfiles = ceil(nBlockPerCPU(j)/MAX_nsmoo);
             ifil(1,j+1) =ifil(1,j)+nfiles;
@@ -295,8 +295,8 @@ else
     NamFileInput(1,:) = {'',[M_.fname '_static.m']};
     NamFileInput(2,:) = {'',[M_.fname '_dynamic.m']};
     NamFileInput(3,:) = {'',[M_.fname '_set_auxiliary_variables.m']};
-    if options_.steadystate_flag,
-        if options_.steadystate_flag == 1,
+    if options_.steadystate_flag
+        if options_.steadystate_flag == 1
             NamFileInput(length(NamFileInput)+1,:)={'',[M_.fname '_steadystate.m']};
         else
             NamFileInput(length(NamFileInput)+1,:)={'',[M_.fname '_steadystate2.m']};
@@ -397,9 +397,9 @@ if options_.filter_covariance
 end
 
 
-if ~isnumeric(options_.parallel),
+if ~isnumeric(options_.parallel)
     options_.parallel_info.leaveSlaveOpen = leaveSlaveOpen;
-    if leaveSlaveOpen == 0,
+    if leaveSlaveOpen == 0
         closeSlave(options_.parallel,options_.parallel_info.RemoteTmpFolder),
     end
 end
\ No newline at end of file
diff --git a/matlab/prior_posterior_statistics_core.m b/matlab/prior_posterior_statistics_core.m
index 3e8e31436..ba505f656 100644
--- a/matlab/prior_posterior_statistics_core.m
+++ b/matlab/prior_posterior_statistics_core.m
@@ -49,7 +49,7 @@ function myoutput=prior_posterior_statistics_core(myinputs,fpar,B,whoiam, ThisMa
 
 global options_ oo_ M_ bayestopt_ estim_params_
 
-if nargin<4,
+if nargin<4
     whoiam=0;
 end
 
@@ -103,9 +103,9 @@ MAX_nruns=myinputs.MAX_nruns;
 MAX_momentsno = myinputs.MAX_momentsno;
 ifil=myinputs.ifil;
 
-if ~strcmpi(type,'prior'),
+if ~strcmpi(type,'prior')
     x=myinputs.x;
-    if strcmpi(type,'posterior'),
+    if strcmpi(type,'posterior')
         logpost=myinputs.logpost;
     end
 end
@@ -128,7 +128,7 @@ end
 
 RemoteFlag = 0;
 if whoiam
-    if Parallel(ThisMatlab).Local==0,
+    if Parallel(ThisMatlab).Local==0
         RemoteFlag =1;
     end
     ifil=ifil(:,whoiam);
@@ -138,7 +138,7 @@ else
 end
 h = dyn_waitbar(prct0,['Taking ',type,' subdraws...']);
 
-if RemoteFlag==1,
+if RemoteFlag==1
     OutputFileName_smooth = {};
     OutputFileName_update = {};
     OutputFileName_inno = {};
@@ -345,14 +345,14 @@ for b=fpar:B
     irun = irun +  ones(13,1);
 
 
-    if run_smoother && (irun(1) > MAX_nsmoo || b == B),
+    if run_smoother && (irun(1) > MAX_nsmoo || b == B)
         stock = stock_smooth(:,:,1:irun(1)-1);
         ifil(1) = ifil(1) + 1;
         save([DirectoryName '/' M_.fname '_smooth' int2str(ifil(1)) '.mat'],'stock');
 
         stock = stock_update(:,:,1:irun(1)-1);
         save([DirectoryName '/' M_.fname '_update' int2str(ifil(1)) '.mat'],'stock');
-        if RemoteFlag==1,
+        if RemoteFlag==1
             OutputFileName_smooth = [OutputFileName_smooth; {[DirectoryName filesep], [M_.fname '_smooth' int2str(ifil(1)) '.mat']}];
             OutputFileName_update = [OutputFileName_update; {[DirectoryName filesep], [M_.fname '_update' int2str(ifil(1)) '.mat']}];
         end
@@ -363,7 +363,7 @@ for b=fpar:B
         stock = stock_innov(:,:,1:irun(2)-1);
         ifil(2) = ifil(2) + 1;
         save([DirectoryName '/' M_.fname '_inno' int2str(ifil(2)) '.mat'],'stock');
-        if RemoteFlag==1,
+        if RemoteFlag==1
             OutputFileName_inno = [OutputFileName_inno; {[DirectoryName filesep], [M_.fname '_inno' int2str(ifil(2)) '.mat']}];
         end
         irun(2) = 1;
@@ -373,7 +373,7 @@ for b=fpar:B
         stock = stock_error(:,:,1:irun(3)-1);
         ifil(3) = ifil(3) + 1;
         save([DirectoryName '/' M_.fname '_error' int2str(ifil(3)) '.mat'],'stock');
-        if RemoteFlag==1,
+        if RemoteFlag==1
             OutputFileName_error = [OutputFileName_error; {[DirectoryName filesep], [M_.fname '_error' int2str(ifil(3)) '.mat']}];
         end
         irun(3) = 1;
@@ -383,7 +383,7 @@ for b=fpar:B
         stock = stock_filter_step_ahead(:,:,:,1:irun(4)-1);
         ifil(4) = ifil(4) + 1;
         save([DirectoryName '/' M_.fname '_filter_step_ahead' int2str(ifil(4)) '.mat'],'stock');
-        if RemoteFlag==1,
+        if RemoteFlag==1
             OutputFileName_filter_step_ahead = [OutputFileName_filter_step_ahead; {[DirectoryName filesep], [M_.fname '_filter_step_ahead' int2str(ifil(4)) '.mat']}];
         end
         irun(4) = 1;
@@ -395,7 +395,7 @@ for b=fpar:B
         stock_ys = stock_ys(1:irun(5)-1,:);
         ifil(5) = ifil(5) + 1;
         save([DirectoryName '/' M_.fname '_param' int2str(ifil(5)) '.mat'],'stock','stock_logpo','stock_ys');
-        if RemoteFlag==1,
+        if RemoteFlag==1
             OutputFileName_param = [OutputFileName_param; {[DirectoryName filesep], [M_.fname '_param' int2str(ifil(5)) '.mat']}];
         end
         irun(5) = 1;
@@ -405,7 +405,7 @@ for b=fpar:B
         stock = stock_forcst_mean(:,:,1:irun(6)-1);
         ifil(6) = ifil(6) + 1;
         save([DirectoryName '/' M_.fname '_forc_mean' int2str(ifil(6)) '.mat'],'stock');
-        if RemoteFlag==1,
+        if RemoteFlag==1
             OutputFileName_forc_mean = [OutputFileName_forc_mean; {[DirectoryName filesep], [M_.fname '_forc_mean' int2str(ifil(6)) '.mat']}];
         end
         irun(6) = 1;
@@ -415,7 +415,7 @@ for b=fpar:B
         stock = stock_forcst_point(:,:,1:irun(7)-1);
         ifil(7) = ifil(7) + 1;
         save([DirectoryName '/' M_.fname '_forc_point' int2str(ifil(7)) '.mat'],'stock');
-        if RemoteFlag==1,
+        if RemoteFlag==1
             OutputFileName_forc_point = [OutputFileName_forc_point; {[DirectoryName filesep], [M_.fname '_forc_point' int2str(ifil(7)) '.mat']}];
         end
         irun(7) = 1;
@@ -425,7 +425,7 @@ for b=fpar:B
         stock = stock_filter_covariance(:,:,:,1:irun(8)-1);
         ifil(8) = ifil(8) + 1;
         save([DirectoryName '/' M_.fname '_filter_covar' int2str(ifil(8)) '.mat'],'stock');
-        if RemoteFlag==1,
+        if RemoteFlag==1
             OutputFileName_filter_covar = [OutputFileName_filter_covar; {[DirectoryName filesep], [M_.fname '_filter_covar' int2str(ifil(8)) '.mat']}];
         end
         irun(8) = 1;
@@ -436,7 +436,7 @@ for b=fpar:B
         stock = stock_trend_coeff(:,1:irun(irun_index)-1);
         ifil(irun_index) = ifil(irun_index) + 1;
         save([DirectoryName '/' M_.fname '_trend_coeff' int2str(ifil(irun_index)) '.mat'],'stock');
-        if RemoteFlag==1,
+        if RemoteFlag==1
             OutputFileName_trend_coeff = [OutputFileName_trend_coeff; {[DirectoryName filesep], [M_.fname '_trend_coeff' int2str(ifil(irun_index)) '.mat']}];
         end
         irun(irun_index) = 1;
@@ -447,7 +447,7 @@ for b=fpar:B
         stock = stock_smoothed_constant(:,:,1:irun(irun_index)-1);
         ifil(irun_index) = ifil(irun_index) + 1;
         save([DirectoryName '/' M_.fname '_smoothed_constant' int2str(ifil(irun_index)) '.mat'],'stock');
-        if RemoteFlag==1,
+        if RemoteFlag==1
             OutputFileName_smoothed_constant = [OutputFileName_smoothed_constant; {[DirectoryName filesep], [M_.fname '_smoothed_constant' int2str(ifil(irun_index)) '.mat']}];
         end
         irun(irun_index) = 1;
@@ -458,7 +458,7 @@ for b=fpar:B
         stock = stock_smoothed_trend(:,:,1:irun(irun_index)-1);
         ifil(irun_index) = ifil(irun_index) + 1;
         save([DirectoryName '/' M_.fname '_smoothed_trend' int2str(ifil(irun_index)) '.mat'],'stock');
-        if RemoteFlag==1,
+        if RemoteFlag==1
             OutputFileName_smoothed_trend = [OutputFileName_smoothed_trend; {[DirectoryName filesep], [M_.fname '_smoothed_trend' int2str(ifil(irun_index)) '.mat']}];
         end
         irun(irun_index) = 1;
@@ -469,7 +469,7 @@ for b=fpar:B
         stock = stock_forcst_point_ME(:,:,1:irun(irun_index)-1);
         ifil(irun_index) = ifil(irun_index) + 1;
         save([DirectoryName '/' M_.fname '_forc_point_ME' int2str(ifil(irun_index)) '.mat'],'stock');
-        if RemoteFlag==1,
+        if RemoteFlag==1
             OutputFileName_forc_point_ME = [OutputFileName_forc_point_ME; {[DirectoryName filesep], [M_.fname '_forc_point_ME' int2str(ifil(irun_index)) '.mat']}];
         end
         irun(irun_index) = 1;
@@ -480,7 +480,7 @@ for b=fpar:B
         stock = stock_smoothed_uncert(:,:,:,1:irun(irun_index)-1);
         ifil(irun_index) = ifil(irun_index) + 1;
         save([DirectoryName '/' M_.fname '_state_uncert' int2str(ifil(irun_index)) '.mat'],'stock');
-        if RemoteFlag==1,
+        if RemoteFlag==1
             OutputFileName_state_uncert = [OutputFileName_state_uncert; {[DirectoryName filesep], [M_.fname '_state_uncert' int2str(ifil(irun_index)) '.mat']}];
         end
         irun(irun_index) = 1;
@@ -490,7 +490,7 @@ for b=fpar:B
 end
 
 myoutput.ifil=ifil;
-if RemoteFlag==1,
+if RemoteFlag==1
     myoutput.OutputFileName = [OutputFileName_smooth;
                         OutputFileName_update;
                         OutputFileName_inno;
diff --git a/matlab/priordens.m b/matlab/priordens.m
index f760680cf..866ae11a3 100644
--- a/matlab/priordens.m
+++ b/matlab/priordens.m
@@ -94,7 +94,7 @@ if tt1
         end
         return
     end
-    if nargout == 2,
+    if nargout == 2
         [tmp, dlprior(id1)]=lpdfgbeta(x(id1),p6(id1),p7(id1),p3(id1),p4(id1));
     elseif nargout == 3
         [tmp, dlprior(id1), d2lprior(id1)]=lpdfgbeta(x(id1),p6(id1),p7(id1),p3(id1),p4(id1));
@@ -109,7 +109,7 @@ if tt2
         end
         return
     end
-    if nargout == 2,
+    if nargout == 2
         [tmp, dlprior(id2)]=lpdfgam(x(id2)-p3(id2),p6(id2),p7(id2));
     elseif nargout == 3
         [tmp, dlprior(id2), d2lprior(id2)]=lpdfgam(x(id2)-p3(id2),p6(id2),p7(id2));
@@ -118,7 +118,7 @@ end
 
 if tt3
     logged_prior_density = logged_prior_density + sum(lpdfnorm(x(id3),p6(id3),p7(id3))) ;
-    if nargout == 2,
+    if nargout == 2
         [tmp, dlprior(id3)]=lpdfnorm(x(id3),p6(id3),p7(id3));
     elseif nargout == 3
         [tmp, dlprior(id3), d2lprior(id3)]=lpdfnorm(x(id3),p6(id3),p7(id3));
@@ -133,7 +133,7 @@ if tt4
         end
         return
     end
-    if nargout == 2,
+    if nargout == 2
         [tmp, dlprior(id4)]=lpdfig1(x(id4)-p3(id4),p6(id4),p7(id4));
     elseif nargout == 3
         [tmp, dlprior(id4), d2lprior(id4)]=lpdfig1(x(id4)-p3(id4),p6(id4),p7(id4));
@@ -149,7 +149,7 @@ if tt5
         return
     end
     logged_prior_density = logged_prior_density + sum(log(1./(p4(id5)-p3(id5)))) ;
-    if nargout >1,
+    if nargout >1
         dlprior(id5)=zeros(length(id5),1);
     end
     if nargout == 3
@@ -165,7 +165,7 @@ if tt6
         end
         return
     end
-    if nargout == 2,
+    if nargout == 2
         [tmp, dlprior(id6)]=lpdfig2(x(id6)-p3(id6),p6(id6),p7(id6));
     elseif nargout == 3
         [tmp, dlprior(id6), d2lprior(id6)]=lpdfig2(x(id6)-p3(id6),p6(id6),p7(id6));
@@ -187,7 +187,7 @@ if tt8
     end
 end
 
-if nargout==3,
+if nargout==3
     d2lprior = diag(d2lprior);
 end
 
diff --git a/matlab/qzdiv.m b/matlab/qzdiv.m
index 2c88184f1..3641808a1 100644
--- a/matlab/qzdiv.m
+++ b/matlab/qzdiv.m
@@ -27,7 +27,7 @@ function [A,B,Q,Z] = qzdiv(stake,A,B,Q,Z)
 % You should have received a copy of the GNU General Public License
 % along with Dynare.  If not, see <http://www.gnu.org/licenses/>.
 
-[n jnk] = size(A);
+[n, jnk] = size(A);
 root = abs([diag(A) diag(B)]);
 root(:,1) = root(:,1)-(root(:,1)<1.e-13).*(root(:,1)+root(:,2));
 root(:,2) = root(:,2)./root(:,1);
@@ -43,7 +43,7 @@ for i = n:-1:1
         return 
     end
     for k=m:1:i-1
-        [A B Q Z] = qzswitch(k,A,B,Q,Z);
+        [A, B, Q, Z] = qzswitch(k,A,B,Q,Z);
         tmp = root(k,2);
         root(k,2) = root(k+1,2);
         root(k+1,2) = tmp;
diff --git a/matlab/realtime_shock_decomposition.m b/matlab/realtime_shock_decomposition.m
index 2cdb6d949..84b73b217 100644
--- a/matlab/realtime_shock_decomposition.m
+++ b/matlab/realtime_shock_decomposition.m
@@ -69,13 +69,13 @@ if isempty(parameter_set)
 end
 
 presample = max(1,options_.presample);
-if isfield(options_.shock_decomp,'presample'),
+if isfield(options_.shock_decomp,'presample')
     presample = max(presample,options_.shock_decomp.presample);
 end
 % forecast_=0;
 forecast_ = options_.shock_decomp.forecast;
 forecast_params=0;
-if forecast_ && isfield(options_.shock_decomp,'forecast_params'),
+if forecast_ && isfield(options_.shock_decomp,'forecast_params')
     forecast_params = options_.shock_decomp.forecast_params;
 end
 
@@ -96,14 +96,14 @@ options_.plot_priors=0;
 init=1;
 nobs = options_.nobs;
 
-if forecast_ && any(forecast_params),
+if forecast_ && any(forecast_params)
     M1=M_;
     M1.params = forecast_params;
     [junk1,junk2,junk3,junk4,junk5,junk6,oo1] = dynare_resolve(M1,options_,oo_);
     clear junk1 junk2 junk3 junk4 junk5 junk6
 end
 
-for j=presample+1:nobs,
+for j=presample+1:nobs
 %    evalin('base',['options_.nobs=' int2str(j) ';'])
     options_.nobs=j;
     [oo, M_, junk2, junk3, Smoothed_Variables_deviation_from_mean] = evaluate_smoother(parameter_set,varlist,M_,oo_,options_,bayestopt_,estim_params_);
@@ -120,8 +120,8 @@ for j=presample+1:nobs,
     A = dr.ghx;
     B = dr.ghu;
     
-    if forecast_,
-        if any(forecast_params),
+    if forecast_
+        if any(forecast_params)
             Af = oo1.dr.ghx;
             Bf = oo1.dr.ghu;
         else
@@ -146,7 +146,7 @@ for j=presample+1:nobs,
     
     k2 = dr.kstate(find(dr.kstate(:,2) <= maximum_lag+1),[1 2]);
     i_state = order_var(k2(:,1))+(min(i,maximum_lag)+1-k2(:,2))*M_.endo_nbr;
-    for i=1:gend+forecast_,
+    for i=1:gend+forecast_
         if i > 1 && i <= maximum_lag+1
             lags = min(i-1,maximum_lag):-1:1;
         end
@@ -173,7 +173,7 @@ for j=presample+1:nobs,
     %% conditional shock decomp 1 step ahead
     z1 = zeros(endo_nbr,nshocks+2);
     z1(:,end) = Smoothed_Variables_deviation_from_mean(:,gend);
-    for i=gend,
+    for i=gend
         
         z1(:,1:nshocks) = z1(:,1:nshocks) + B(inv_order_var,:).*repmat(epsilon(:,i)',endo_nbr,1);
         z1(:,nshocks+1) = z1(:,nshocks+2) - sum(z1(:,1:nshocks),2);
@@ -181,10 +181,10 @@ for j=presample+1:nobs,
     %%
 
     %% conditional shock decomp k step ahead
-    if forecast_ && forecast_<j,
+    if forecast_ && forecast_<j
         zn = zeros(endo_nbr,nshocks+2,forecast_+1);
         zn(:,end,1:forecast_+1) = Smoothed_Variables_deviation_from_mean(:,gend-forecast_:gend);
-        for i=1:forecast_+1,
+        for i=1:forecast_+1
             if i > 1 && i <= maximum_lag+1
                 lags = min(i-1,maximum_lag):-1:1;
             end
@@ -205,7 +205,7 @@ for j=presample+1:nobs,
     end
     %%
        
-    if init,
+    if init
         zreal(:,:,1:j) = z(:,:,1:j);
     else
         zreal(:,:,j) = z(:,:,gend);
@@ -229,7 +229,7 @@ for j=presample+1:nobs,
                 zreal(:,end,j-forecast_:j);
     
             if j==nobs
-                for my_forecast_=(forecast_-1):-1:1,
+                for my_forecast_=(forecast_-1):-1:1
                     oo_.realtime_conditional_shock_decomposition.(['time_' int2str(j-my_forecast_)]) = ...
                         zreal(:,:,j-my_forecast_:j) - ...
                         oo_.realtime_forecast_shock_decomposition.(['time_' int2str(j-my_forecast_)])(:,:,1:my_forecast_+1);
diff --git a/matlab/reduced_rank_cholesky.m b/matlab/reduced_rank_cholesky.m
index 1af9ec609..99e9ea2ec 100644
--- a/matlab/reduced_rank_cholesky.m
+++ b/matlab/reduced_rank_cholesky.m
@@ -87,7 +87,7 @@ end
 %$ catch
 %$    t(1) = 0;
 %$    T = all(t);
-%$    return;
+%$    return
 %$ end
 %$
 %$
diff --git a/matlab/resol.m b/matlab/resol.m
index 0fae31a9e..b1e770f90 100644
--- a/matlab/resol.m
+++ b/matlab/resol.m
@@ -93,7 +93,7 @@ function [dr,info,M,options,oo] = resol(check_flag,M,options,oo)
 % You should have received a copy of the GNU General Public License
 % along with Dynare.  If not, see <http://www.gnu.org/licenses/>.
 
-if isfield(oo,'dr');
+if isfield(oo,'dr')
     dr = oo.dr;
 end
 
diff --git a/matlab/rotated_slice_sampler.m b/matlab/rotated_slice_sampler.m
index 66908d77d..ce6b18235 100644
--- a/matlab/rotated_slice_sampler.m
+++ b/matlab/rotated_slice_sampler.m
@@ -45,13 +45,13 @@ theta=theta(:);
 npar = length(theta);
 neval = zeros(npar,1);
 W1=[];
-if isfield(sampler_options,'WR'),
+if isfield(sampler_options,'WR')
     W1 = sampler_options.WR;
 end
-if ~isempty(sampler_options.mode),
+if ~isempty(sampler_options.mode)
     mm = sampler_options.mode;
     n = length(mm);
-    for j=1:n,
+    for j=1:n
         distance(j)=sqrt(sum((theta-mm(j).m).^2));
     end
     [m, im] = min(distance);
@@ -59,8 +59,8 @@ if ~isempty(sampler_options.mode),
     r=im;
     V1 = mm(r).m;
     jj=0;
-    for j=1:n,
-        if j~=r,
+    for j=1:n
+        if j~=r
             jj=jj+1;
             tmp=mm(j).m-mm(r).m;
             %tmp=mm(j).m-theta;
@@ -102,7 +102,7 @@ else
 end
 npar=size(V1,2);
     
-for it=1:npar,
+for it=1:npar
     theta0 = theta;
     neval(it) = 0;
     xold  = 0;
@@ -111,7 +111,7 @@ for it=1:npar,
     tb=sort([(thetaprior(:,1)-theta)./V1(:,it) (thetaprior(:,2)-theta)./V1(:,it)],2);
     XLB=max(tb(:,1));
     XUB=min(tb(:,2));  
-    if isempty(W1),
+    if isempty(W1)
         W = (XUB-XLB); %*0.8; 
     else
         W = W1(it);
@@ -141,7 +141,7 @@ for it=1:npar,
         fxl = -feval(objective_function,theta,varargin{:});
         neval(it) = neval(it) + 1;
         if (fxl <= Z)
-            break;
+            break
         end
         L = max(XLB,L-W);
     end
@@ -151,7 +151,7 @@ for it=1:npar,
         fxr = -feval(objective_function,theta,varargin{:});
         neval(it) = neval(it) + 1;
         if (fxr <= Z)
-            break;
+            break
         end
         R = min(XUB,R+W);
     end
diff --git a/matlab/select_from_table.m b/matlab/select_from_table.m
index cc657e934..fa61003f1 100644
--- a/matlab/select_from_table.m
+++ b/matlab/select_from_table.m
@@ -18,7 +18,7 @@ function [indices] = select_from_table(table,key,value)
 candidates = table(strmatch(key,table(:,2),'exact'),:);
 if nargin == 2
     indices = cell2mat( candidates(:,1) );
-    return;
+    return
 end
 indices = candidates(strmatch(value, candidates(:,3), 'exact'),1);
 indices = cell2mat(indices);
diff --git a/matlab/set_state_space.m b/matlab/set_state_space.m
index a7d108165..a99a556f5 100644
--- a/matlab/set_state_space.m
+++ b/matlab/set_state_space.m
@@ -73,7 +73,7 @@ if DynareOptions.block == 1
     order_var = DynareModel.block_structure.variable_reordered;
 else
     order_var = [ stat_var(:); pred_var(:); both_var(:); fwrd_var(:)];
-end;
+end
 inv_order_var(order_var) = (1:endo_nbr);
 
 % building kmask for z state vector in t+1
diff --git a/matlab/simulated_moment_uncertainty.m b/matlab/simulated_moment_uncertainty.m
index 042f9914a..ef9358a75 100644
--- a/matlab/simulated_moment_uncertainty.m
+++ b/matlab/simulated_moment_uncertainty.m
@@ -94,17 +94,17 @@ else
 end
 
 
-for j=1:replic;
+for j=1:replic
     [ys, oo_] = simult(y0,oo_.dr,M_,options_,oo_);%do simulation
     oo_=disp_moments(ys,char(options_.varobs),M_,options_,oo_); %get moments
     dum=[oo_.mean; dyn_vech(oo_.var)];
     sd = sqrt(diag(oo_.var));
-    for i=1:options_.ar;
+    for i=1:options_.ar
         dum=[dum; vec(oo_.autocorr{i}.*(sd*sd'))];
     end
     mm(:,j)=dum(indx);
     dyn_waitbar(j/replic,h,['Simulated moment uncertainty. Replic  ',int2str(j),'/',int2str(replic)])
-end;
+end
 dyn_waitbar_close(h);
 
 if logged_steady_state_indicator
diff --git a/matlab/simulated_moments_estimation.m b/matlab/simulated_moments_estimation.m
index 314122d83..62f077de8 100644
--- a/matlab/simulated_moments_estimation.m
+++ b/matlab/simulated_moments_estimation.m
@@ -282,7 +282,7 @@ fprintf(fid,['    time_series = extended_path([],' int2str(sample_size) ',1);\n'
 fprintf(fid,['    data = time_series([' int2str(observed_variables_idx) '],' int2str(burn_in_periods) '+1:' int2str(sample_size) ');\n']);
 fprintf(fid,['    eval(''tmp = ' moments_file_name '(data);'');\n']);
 fprintf(fid,['    simulated_moments = simulated_moments + tmp;\n']);
-fprintf(fid,['end;\n\n']);
+fprintf(fid,['end\n\n']);
 
 fprintf(fid,['simulated_moments = simulated_moments/' int2str(number_of_simulations) ';\n']);
 fprintf(fid,['save(''simulated_moments_slave_' int2str(slave_number) '.dat'',''simulated_moments'',''-ascii'');\n']);
diff --git a/matlab/simult_.m b/matlab/simult_.m
index 31daa3a6c..ff0b42f9e 100644
--- a/matlab/simult_.m
+++ b/matlab/simult_.m
@@ -77,14 +77,14 @@ else
             k2 = dr.state_var;
         else
             k2 = [];
-        end;
+        end
         order_var = 1:endo_nbr;
         dr.order_var = order_var;
     else
         k2 = dr.kstate(find(dr.kstate(:,2) <= M_.maximum_lag+1),[1 2]);
         k2 = k2(:,1)+(M_.maximum_lag+1-k2(:,2))*endo_nbr;
         order_var = dr.order_var;
-    end;
+    end
     
     switch iorder
       case 1
diff --git a/matlab/slice_sampler.m b/matlab/slice_sampler.m
index e454d5936..ef524fd4e 100644
--- a/matlab/slice_sampler.m
+++ b/matlab/slice_sampler.m
@@ -43,8 +43,8 @@ function [theta, fxsim, neval] = slice_sampler(objective_function,theta,thetapri
 
 if sampler_options.rotated %&& ~isempty(sampler_options.V1),
     [theta, fxsim, neval] = rotated_slice_sampler(objective_function,theta,thetaprior,sampler_options,varargin{:});
-    if isempty(sampler_options.mode), % jumping 
-       return,
+    if isempty(sampler_options.mode) % jumping 
+       return
     else
         nevalR=sum(neval);
     end    
@@ -55,7 +55,7 @@ npar = length(theta);
 W1 = sampler_options.W1;
 neval = zeros(npar,1);
 
-for it=1:npar,
+for it=1:npar
     neval(it) = 0;
     W = W1(it); 
     xold  = theta(it);
@@ -85,7 +85,7 @@ for it=1:npar,
         fxl = -feval(objective_function,theta,varargin{:});
         neval(it) = neval(it) + 1;
         if (fxl <= Z)
-            break;
+            break
         end
         L = max(XLB,L-W);
     end
@@ -95,7 +95,7 @@ for it=1:npar,
         fxr = -feval(objective_function,theta,varargin{:});
         neval(it) = neval(it) + 1;
         if (fxr <= Z)
-            break;
+            break
         end
         R = min(XUB,R+W);
     end
@@ -118,6 +118,6 @@ for it=1:npar,
     
 end
 
-if sampler_options.rotated && ~isempty(sampler_options.mode), % jumping
+if sampler_options.rotated && ~isempty(sampler_options.mode) % jumping
     neval=sum(neval)+nevalR;
 end
diff --git a/matlab/smm_objective.m b/matlab/smm_objective.m
index 030cb98d9..46a941b47 100644
--- a/matlab/smm_objective.m
+++ b/matlab/smm_objective.m
@@ -68,7 +68,7 @@ end
 if penalty>0
     flag = 0;
     r = priorObjectiveValue + penalty; 
-    return;
+    return
 end
 
 save('estimated_parameters.mat','xparams');
diff --git a/matlab/solve1.m b/matlab/solve1.m
index 5d5241fce..6ce89ca62 100644
--- a/matlab/solve1.m
+++ b/matlab/solve1.m
@@ -59,7 +59,7 @@ if ~isempty(i)
           'equation(s) resulted in a non-finite number:'])
     disp(j1(i)')
     check = 1;
-    return;
+    return
 end
 
 f = 0.5*(fvec'*fvec) ;
diff --git a/matlab/solve_one_boundary.m b/matlab/solve_one_boundary.m
index 2ce90c7bc..261ab3018 100644
--- a/matlab/solve_one_boundary.m
+++ b/matlab/solve_one_boundary.m
@@ -387,7 +387,7 @@ for it_=start:incr:finish
             oo_.deterministic_simulation.block(Block_Num).status = 0;% Convergency failed.
             oo_.deterministic_simulation.block(Block_Num).error = max_res;
             oo_.deterministic_simulation.block(Block_Num).iterations = iter;
-        end;
+        end
         info = -Block_Num*10;
         return
     end
diff --git a/matlab/solve_perfect_foresight_model.m b/matlab/solve_perfect_foresight_model.m
index 5de112ad8..02a6c234f 100644
--- a/matlab/solve_perfect_foresight_model.m
+++ b/matlab/solve_perfect_foresight_model.m
@@ -34,7 +34,7 @@ function [flag,endo_simul,err] = solve_perfect_foresight_model(endo_simul,exo_si
 
     if pfm.use_bytecode
         [flag, endo_simul]=bytecode(Y, exo_simul, pfm.params);
-        return;
+        return
     end
 
     z = Y(find(pfm.lead_lag_incidence'));
diff --git a/matlab/solve_two_boundaries.m b/matlab/solve_two_boundaries.m
index 136d3e1ac..7f0df6530 100644
--- a/matlab/solve_two_boundaries.m
+++ b/matlab/solve_two_boundaries.m
@@ -92,7 +92,7 @@ while ~(cvg==1 || iter>maxit_)
     [max_res, max_indx]=max(max(abs(r')));
     if ~isreal(r)
         max_res = (-max_res^2)^0.5;
-    end;
+    end
     if ~isreal(max_res) || isnan(max_res)
         cvg = 0;
     elseif(is_linear && iter>0)
@@ -123,7 +123,7 @@ while ~(cvg==1 || iter>maxit_)
                             end
                             dx = (g1aa+correcting_factor*speye(periods*Blck_size))\ba- ya;
                             y(1+y_kmin:periods+y_kmin,y_index)=reshape((ya_save+lambda*dx)',length(y_index),periods)';
-                            continue;
+                            continue
                         else
                             disp('The singularity of the jacobian matrix could not be corrected');
                             return
@@ -178,7 +178,7 @@ while ~(cvg==1 || iter>maxit_)
                 B1_inv = inv(g1a(Elem, Elem));
                 if (t < periods)
                     S1 = B1_inv * g1a(Elem, Elem_1);
-                end;
+                end
                 g1a(Elem, Elem_1) = S1;
                 b(Elem) = B1_inv * b(Elem);
                 g1a(Elem, Elem) = ones(Blck_size, Blck_size);
diff --git a/matlab/stoch_simul.m b/matlab/stoch_simul.m
index 5465eaa96..b77cacc3a 100644
--- a/matlab/stoch_simul.m
+++ b/matlab/stoch_simul.m
@@ -324,7 +324,7 @@ if options_.irf
                     end
                     hh = dyn_figure(options_.nodisplay,'Name',['Orthogonalized shock to ' tit(i,:) ' figure ' int2str(nbplt) '.']);
                     m = 0;
-                    for plt = 1:number_of_plots_to_draw-(nbplt-1)*nstar;
+                    for plt = 1:number_of_plots_to_draw-(nbplt-1)*nstar
                         m = m+1;
                         subplot(lr,lc,m);
                         plot(1:options_.irf,transpose(irfs((nbplt-1)*nstar+plt,:)),'-k','linewidth',1);
diff --git a/matlab/stochastic_solvers.m b/matlab/stochastic_solvers.m
index 7332654a8..b7da41258 100644
--- a/matlab/stochastic_solvers.m
+++ b/matlab/stochastic_solvers.m
@@ -85,7 +85,7 @@ if M_.maximum_endo_lead==0 && M_.exo_det_nbr~=0
     error(['var_exo_det not implemented for purely backwards models'])
 end
 
-if options_.k_order_solver;
+if options_.k_order_solver
     if options_.risky_steadystate
         [dr,info] = dyn_risky_steadystate_solver(oo_.steady_state,M_,dr, ...
                                              options_,oo_);
@@ -96,7 +96,7 @@ if options_.k_order_solver;
         [dr,info] = k_order_pert(dr,M_,options_);
         options_.order = orig_order;
     end
-    return;
+    return
 end
 
 klen = M_.maximum_lag + M_.maximum_lead + 1;
@@ -120,7 +120,7 @@ if local_order == 1
     else
         [junk,jacobia_] = feval([M_.fname '_dynamic'],z(iyr0),exo_simul, ...
                             M_.params, dr.ys, it_);
-    end;
+    end
 elseif local_order == 2
     if (options_.bytecode)
         [chck, junk, loc_dr] = bytecode('dynamic','evaluate', z,exo_simul, ...
@@ -130,7 +130,7 @@ elseif local_order == 2
         [junk,jacobia_,hessian1] = feval([M_.fname '_dynamic'],z(iyr0),...
                                          exo_simul, ...
                                          M_.params, dr.ys, it_);
-    end;
+    end
     if options_.use_dll
         % In USE_DLL mode, the hessian is in the 3-column sparse representation
         hessian1 = sparse(hessian1(:,1), hessian1(:,2), hessian1(:,3), ...
@@ -263,7 +263,7 @@ else
     else  % use original Dynare solver
         [dr,info] = dyn_first_order_solver(jacobia_,M_,dr,options_,task);
         if info(1) || task
-            return;
+            return
         end
     end
 
diff --git a/matlab/th_autocovariances.m b/matlab/th_autocovariances.m
index 966ece834..cac209729 100644
--- a/matlab/th_autocovariances.m
+++ b/matlab/th_autocovariances.m
@@ -114,7 +114,7 @@ else
     trend = 1:M_.endo_nbr;
     inv_order_var = trend(M_.block_structure.variable_reordered);
     ghu1(1:length(dr.state_var),:) = ghu(dr.state_var,:);
-end;
+end
 b = ghu1*M_.Sigma_e*ghu1';
 
 
@@ -122,7 +122,7 @@ if options_.block == 0
     ipred = nstatic+(1:nspred)';
 else
     ipred = dr.state_var;
-end;
+end
 % state space representation for state variables only
 [A,B] = kalman_transition_matrix(dr,ipred,1:nx,M_.exo_nbr);
 % Compute stationary variables (before HP filtering),
@@ -134,7 +134,7 @@ if options_.order == 2 || options_.hp_filter == 0
         iky = inv_order_var(ivar);
     else
         iky = ivar;
-    end;
+    end
     stationary_vars = (1:length(ivar))';
     if ~isempty(u)
         x = abs(ghx*u);
@@ -233,7 +233,7 @@ else% ==> Theoretical filters.
     IA = eye(size(A,1));
     IE = eye(M_.exo_nbr);
     for ig = 1:ngrid
-        if filter_gain(ig)==0,
+        if filter_gain(ig)==0
             f_hp = zeros(length(ivar),length(ivar));
         else
             f_omega  =(1/(2*pi))*([(IA-A*tneg(ig))\ghu1;IE]...
@@ -242,7 +242,7 @@ else% ==> Theoretical filters.
             f_hp = filter_gain(ig)^2*g_omega; % spectral density of selected filtered series; top formula Uhlig (2001), p. 21;
         end
         mathp_col(ig,:) = (f_hp(:))';    % store as matrix row for ifft
-    end;
+    end
     % Covariance of filtered series
     imathp_col = real(ifft(mathp_col))*(2*pi); % Inverse Fast Fourier Transformation; middle formula Uhlig (2001), p. 21;
     Gamma_y{1} = reshape(imathp_col(1,:),nvar,nvar);
@@ -269,7 +269,7 @@ else% ==> Theoretical filters.
             IA = eye(size(A,1));
             IE = eye(M_.exo_nbr);
             for ig = 1:ngrid
-                if filter_gain(ig)==0,
+                if filter_gain(ig)==0
                     f_hp = zeros(length(ivar),length(ivar));
                 else
                     f_omega  =(1/(2*pi))*( [(IA-A*tneg(ig))\b1;IE]...
@@ -278,14 +278,14 @@ else% ==> Theoretical filters.
                     f_hp = filter_gain(ig)^2*g_omega;  % spectral density of selected filtered series; top formula Uhlig (2001), p. 21;
                 end
                 mathp_col(ig,:) = (f_hp(:))';    % store as matrix row for ifft
-            end;  
+            end
             imathp_col = real(ifft(mathp_col))*(2*pi);
             vv = diag(reshape(imathp_col(1,:),nvar,nvar));
             for i=1:M_.exo_nbr
                 mathp_col = NaN(ngrid,length(ivar)^2);
                 SSi = cs(:,i)*cs(:,i)';
                 for ig = 1:ngrid
-                    if filter_gain(ig)==0,
+                    if filter_gain(ig)==0
                         f_hp = zeros(length(ivar),length(ivar));
                     else
                         f_omega  =(1/(2*pi))*( [(IA-A*tneg(ig))\b1;IE]...
@@ -294,7 +294,7 @@ else% ==> Theoretical filters.
                         f_hp = filter_gain(ig)^2*g_omega; % spectral density of selected filtered series; top formula Uhlig (2001), p. 21;
                     end
                     mathp_col(ig,:) = (f_hp(:))';    % store as matrix row for ifft
-                end;
+                end
                 imathp_col = real(ifft(mathp_col))*(2*pi);
                 Gamma_y{nar+2}(:,i) = abs(diag(reshape(imathp_col(1,:),nvar,nvar)))./vv;
             end
diff --git a/matlab/thet2tau.m b/matlab/thet2tau.m
index 929193ca4..2fc9625c8 100644
--- a/matlab/thet2tau.m
+++ b/matlab/thet2tau.m
@@ -20,22 +20,22 @@ function tau = thet2tau(params, estim_params_, M_, oo_, indx, indexo, flagmoment
 
 global options_
 
-if nargin==1,
+if nargin==1
     indx = [1:M_.param_nbr];
     indexo = [];
 end
 
-if nargin<7,
+if nargin<7
     flagmoments=0;
 end
-if nargin<10 || isempty(useautocorr),
+if nargin<10 || isempty(useautocorr)
     useautocorr=0;
 end
-if nargin<11 || isempty(iv),
+if nargin<11 || isempty(iv)
     iv=[1:M_.endo_nbr];
 end
 
-if length(params)>length(indx),
+if length(params)>length(indx)
     M_ = set_all_parameters(params,estim_params_,M_);
 else
     M_.params(indx) = params;
@@ -44,7 +44,7 @@ end
 %     M_.Sigma_e(indexo,indexo) = diag(params(1:length(indexo)).^2);
 % end
 [A,B,tele,tubbies,M_,options_,oo_] = dynare_resolve(M_,options_,oo_);
-if flagmoments==0,
+if flagmoments==0
     ys=oo_.dr.ys(oo_.dr.order_var);
     tau = [ys(iv); vec(A(iv,iv)); dyn_vech(B(iv,:)*M_.Sigma_e*B(iv,:)')];
 elseif flagmoments==-1
@@ -58,7 +58,7 @@ else
     GAM =  lyapunov_symm(A,B*M_.Sigma_e*B',options_.lyapunov_fixed_point_tol,options_.qz_criterium,options_.lyapunov_complex_threshold,[],options_.debug);
     k = find(abs(GAM) < 1e-12);
     GAM(k) = 0;
-    if useautocorr,
+    if useautocorr
         sy = sqrt(diag(GAM));
         sy = sy*sy';
         sy0 = sy-diag(diag(sy))+eye(length(sy));
@@ -69,7 +69,7 @@ else
     end
     for ii = 1:nlags
         dum = A^(ii)*GAM;
-        if useautocorr,
+        if useautocorr
             dum = dum./sy;
         end
         tau = [tau;vec(dum(mf,mf))];
diff --git a/matlab/trust_region.m b/matlab/trust_region.m
index 02acae0c5..5e21d0fbb 100644
--- a/matlab/trust_region.m
+++ b/matlab/trust_region.m
@@ -150,7 +150,7 @@ while (niter < maxiter && ~info)
             else
                 info = -3;
             end
-            break;
+            break
         end
     elseif (abs (1-ratio) <= 0.1)
         delta = 1.4142*sn;
diff --git a/matlab/user_has_matlab_license.m b/matlab/user_has_matlab_license.m
index 86b8c94bd..190589392 100644
--- a/matlab/user_has_matlab_license.m
+++ b/matlab/user_has_matlab_license.m
@@ -31,7 +31,7 @@ function [hasLicense] = user_has_matlab_license(toolbox)
 if matlab_ver_less_than('7.12')
     hasLicense = license('test', toolbox);
 else
-    [hasLicense junk] = license('checkout',toolbox);
+    [hasLicense, junk] = license('checkout',toolbox);
 end
 if ~hasLicense
     return
@@ -50,7 +50,7 @@ end
 hasInstallation=check_toolbox_installation(n);
 if ~hasInstallation
     hasLicense=0;
-    return;
+    return
 end
 end
 
diff --git a/matlab/utilities/dataset/lagged.m b/matlab/utilities/dataset/lagged.m
index 31a58909a..fa84577e2 100644
--- a/matlab/utilities/dataset/lagged.m
+++ b/matlab/utilities/dataset/lagged.m
@@ -1,4 +1,4 @@
-function xlag = lagged(x, n);
+function xlag = lagged(x, n)
 % xlag = lagged(x, n);
 % applies n-lags backward shift operator to x
 % 
@@ -26,7 +26,9 @@ function xlag = lagged(x, n);
 % You should have received a copy of the GNU General Public License
 % along with Dynare.  If not, see <http://www.gnu.org/licenses/>.
 
-if nargin==1, n=1; end
+if nargin==1
+    n=1;
+end
 
 x=x(:);
-xlag=[NaN(n,1); x(1:end-n)];
+xlag=[NaN(n,1); x(1:end-n)];
\ No newline at end of file
diff --git a/matlab/utilities/dataset/quarterly2annual.m b/matlab/utilities/dataset/quarterly2annual.m
index cc655f1e0..c74111bf9 100644
--- a/matlab/utilities/dataset/quarterly2annual.m
+++ b/matlab/utilities/dataset/quarterly2annual.m
@@ -43,18 +43,18 @@ function [ya, yass, gya, gyass] = quarterly2annual(y,yss,GYTREND0,type,islog,aux
 % You should have received a copy of the GNU General Public License
 % along with Dynare.  If not, see <http://www.gnu.org/licenses/>.
 
-if nargin ==0,
+if nargin ==0
     disp('[ya, yass, gya, gyass] = quarterly2annual(y,yss,GYTREND0,type,islog);')
     return
 end
 
-if nargin<4 || isempty(type),
+if nargin<4 || isempty(type)
     type=1;
 end
-if nargin<5 || isempty(islog),
+if nargin<5 || isempty(islog)
     islog=0;
 end
-if isstruct(aux),
+if isstruct(aux)
     yaux=aux.y;
     yauxss=aux.yss;
     islogaux=aux.islog;
@@ -65,10 +65,10 @@ if isstruct(aux),
         yauxss=exp(yauxss);
         yaux=yaux-yauxss;
     end
-elseif type > 4,
+elseif type > 4
     error('TYPE>4 requires auxiliary variable!')
 end
-if islog == 2,
+if islog == 2
     % construct loglevel out of growth rate
     y = cumsum(y);
     yss=0;
@@ -80,28 +80,23 @@ if islog == 1
     y=y-yss;
 end
 switch type
-
     case 1
         yass = yss*(exp(-GYTREND0*3)+exp(-GYTREND0*2)+exp(-GYTREND0)+1);
         tmp = lagged(y,3)*exp(-GYTREND0*3)+lagged(y,2)*exp(-GYTREND0*2)+lagged(y,1)*exp(-GYTREND0)+y; % annualized level
         ya = tmp(4:4:end);
-
     case 2
         yass = yss*(exp(-GYTREND0*3)+exp(-GYTREND0*2)+exp(-GYTREND0)+1)/4;
         tmp = (lagged(y,3)*exp(-GYTREND0*3)+lagged(y,2)*exp(-GYTREND0*2)+lagged(y,1)*exp(-GYTREND0)+y)/4; % annualized level
         ya = tmp(4:4:end);
-
     case 3
         yass=yss;
         tmp = y;
         ya = tmp(4:4:end);
-        
     case 4
         yass = yss*(exp(-GYTREND0*3/2));
         tmp = (lagged(y+yss,3)*exp(-GYTREND0*3).*lagged(y+yss,2)*exp(-GYTREND0*2).*lagged(y+yss,1)*exp(-GYTREND0).*(y+yss)).^(1/4); % annualized level        
         tmp = tmp - yass;
         ya = tmp(4:4:end);
-
     case 5
         % nominal series
         yn = (y+yss).*(yaux+yauxss) - yss.*yauxss;
@@ -111,7 +106,6 @@ switch type
         % deflator
         yass = ynass/yrass;
         ya = (yna+ynass)./(yr+yrass)-yass;        
-        
     case 6
         % nominal series
         yn = (y+yss).*(yaux+yauxss) - yss.*yauxss;
@@ -121,13 +115,11 @@ switch type
         % real series
         yass = ynass/pass;
         ya = (yna+ynass)./(pa+pass)-yass;        
-
     case 7
         % nominal series
         yn = (y+yss).*(yaux+yauxss) - yss.*yauxss;
         [ya, yass] = quarterly2annual(yn,yss.*yauxss,GYTREND0+GYTREND0aux,typeaux,0,0);
         GYTREND0=GYTREND0+GYTREND0aux;
-
     otherwise
         error('Wrong type input')
 end
diff --git a/matlab/utilities/graphics/colorspace.m b/matlab/utilities/graphics/colorspace.m
index dc46d5e85..a26091472 100644
--- a/matlab/utilities/graphics/colorspace.m
+++ b/matlab/utilities/graphics/colorspace.m
@@ -155,7 +155,7 @@ else
    varargout = {Image};
 end
 
-return;
+return
 
 
 function [SrcSpace,DestSpace] = parse(Str)
@@ -186,7 +186,7 @@ else
    DestSpace = Conversion;
    if any(size(Conversion) ~= 3), error('Transformation matrix must be 3x3.'); end
 end
-return;
+return
 
 
 function Space = alias(Space)
@@ -204,9 +204,9 @@ case {'hsv','hsb'}
 case {'hsl','hsi','hls'}
    Space = 'hsl';
 case {'rgb','yuv','yiq','ydbdr','ycbcr','jpegycbcr','xyz','lab','luv','lch'}
-   return;
+   return
 end
-return;
+return
 
 
 function T = gettransform(Space)
@@ -240,14 +240,14 @@ case {'rgb','xyz','hsv','hsl','lab','luv','lch','cat02lms'}
 otherwise
    error(['Unknown color space, ''',Space,'''.']);
 end
-return;
+return
 
 
 function Image = rgb(Image,SrcSpace)
 % Convert to sRGB from 'SrcSpace'
 switch SrcSpace
 case 'rgb'
-   return;
+   return
 case 'hsv'
    % Convert HSV to sRGB
    Image = huetorgb((1 - Image(:,:,2)).*Image(:,:,3),Image(:,:,3),Image(:,:,1));
@@ -287,7 +287,7 @@ end
 
 % Clip to [0,1]
 Image = min(max(Image,0),1);
-return;
+return
 
 
 function Image = xyz(Image,SrcSpace)
@@ -296,7 +296,7 @@ WhitePoint = [0.950456,1,1.088754];
 
 switch SrcSpace
 case 'xyz'
-   return;
+   return
 case 'luv'
    % Convert CIE L*uv to XYZ
    WhitePointU = (4*WhitePoint(1))./(WhitePoint(1) + 15*WhitePoint(2) + 3*WhitePoint(3));
@@ -340,7 +340,7 @@ otherwise   % Convert from some gamma-corrected space
    Image(:,:,2) = T(2)*R + T(5)*G + T(8)*B;  % Y
    Image(:,:,3) = T(3)*R + T(6)*G + T(9)*B;  % Z
 end
-return;
+return
 
 
 function Image = hsv(Image,SrcSpace)
@@ -351,7 +351,7 @@ S = (V - min(Image,[],3))./(V + (V == 0));
 Image(:,:,1) = rgbtohue(Image);
 Image(:,:,2) = S;
 Image(:,:,3) = V;
-return;
+return
 
 
 function Image = hsl(Image,SrcSpace)
@@ -377,7 +377,7 @@ otherwise
    Image(:,:,2) = S;
    Image(:,:,3) = L;
 end
-return;
+return
 
 
 function Image = lab(Image,SrcSpace)
@@ -386,7 +386,7 @@ WhitePoint = [0.950456,1,1.088754];
 
 switch SrcSpace
 case 'lab'
-   return;
+   return
 case 'lch'
    % Convert CIE L*CH to CIE L*ab
    C = Image(:,:,2);
@@ -405,7 +405,7 @@ otherwise
    Image(:,:,2) = 500*(fX - fY);  % a*
    Image(:,:,3) = 200*(fY - fZ);  % b*
 end
-return;
+return
 
 
 function Image = luv(Image,SrcSpace)
@@ -423,7 +423,7 @@ L = 116*f(Y) - 16;
 Image(:,:,1) = L;                        % L*
 Image(:,:,2) = 13*L.*(U - WhitePointU);  % u*
 Image(:,:,3) = 13*L.*(V - WhitePointV);  % v*
-return;  
+return
 
 
 function Image = lch(Image,SrcSpace)
@@ -433,7 +433,7 @@ H = atan2(Image(:,:,3),Image(:,:,2));
 H = H*180/pi + 360*(H < 0);
 Image(:,:,2) = sqrt(Image(:,:,2).^2 + Image(:,:,3).^2);  % C
 Image(:,:,3) = H;                                        % H
-return;
+return
 
 
 function Image = cat02lms(Image,SrcSpace)
@@ -446,7 +446,7 @@ Z = Image(:,:,3);
 Image(:,:,1) = T(1)*X + T(4)*Y + T(7)*Z;  % L
 Image(:,:,2) = T(2)*X + T(5)*Y + T(8)*Z;  % M
 Image(:,:,3) = T(3)*X + T(6)*Y + T(9)*Z;  % S
-return;
+return
 
 
 function Image = huetorgb(m0,m2,H)
@@ -461,7 +461,7 @@ Num = length(m0);
 j = [2 1 0;1 2 0;0 2 1;0 1 2;1 0 2;2 0 1;2 1 0]*Num;
 k = floor(H) + 1;
 Image = reshape([M(j(k,1)+(1:Num).'),M(j(k,2)+(1:Num).'),M(j(k,3)+(1:Num).')],[N,3]);
-return;
+return
 
 
 function H = rgbtohue(Image)
@@ -482,7 +482,7 @@ k = (i == 3);
 H(k) = 4 + (R(k) - G(k))./Delta(k);
 H = 60*H + 360*(H < 0);
 H(Delta == 0) = nan;
-return;
+return
 
 
 function Rp = gammacorrection(R)
@@ -490,7 +490,7 @@ Rp = zeros(size(R));
 i = (R <= 0.0031306684425005883);
 Rp(i) = 12.92*R(i);
 Rp(~i) = real(1.055*R(~i).^0.416666666666666667 - 0.055);
-return;
+return
 
 
 function R = invgammacorrection(Rp)
@@ -498,18 +498,18 @@ R = zeros(size(Rp));
 i = (Rp <= 0.0404482362771076);
 R(i) = Rp(i)/12.92;
 R(~i) = real(((Rp(~i) + 0.055)/1.055).^2.4);
-return;
+return
 
 
 function fY = f(Y)
 fY = real(Y.^(1/3));
 i = (Y < 0.008856);
 fY(i) = Y(i)*(841/108) + (4/29);
-return;
+return
 
 
 function Y = invf(fY)
 Y = fY.^3;
 i = (Y < 0.008856);
 Y(i) = (fY(i) - 4/29)*(108/841);
-return;
+return
diff --git a/matlab/utilities/graphics/distinguishable_colors.m b/matlab/utilities/graphics/distinguishable_colors.m
index 0b9fb7a33..cf45e582d 100644
--- a/matlab/utilities/graphics/distinguishable_colors.m
+++ b/matlab/utilities/graphics/distinguishable_colors.m
@@ -162,9 +162,9 @@ k = find(cspec==c(1));
 if isempty(k)
     error('MATLAB:InvalidColorString','Unknown color string.');
 end
-if k~=3 || length(c)==1,
+if k~=3 || length(c)==1
     c = rgbspec(k,:);
-elseif length(c)>2,
+elseif length(c)>2
     if strcmpi(c(1:3),'bla')
         c = [0 0 0];
     elseif strcmpi(c(1:3),'blu')
diff --git a/matlab/ver_greater_than.m b/matlab/ver_greater_than.m
index 1fef34bf2..9388d15ef 100644
--- a/matlab/ver_greater_than.m
+++ b/matlab/ver_greater_than.m
@@ -36,27 +36,27 @@ ver2 = strsplit(ver2, {'.', '-'});
 maj_ver1 = str2double(ver1{1});
 maj_ver2 = str2double(ver2{1});
 if maj_ver1 > maj_ver2
-    return;
+    return
 end
 
 min_ver1 = str2double(ver1{2});
 min_ver2 = str2double(ver2{2});
 if (maj_ver1 == maj_ver2) && (min_ver1 > min_ver2)
-    return;
+    return
 end
 
 if (length(ver1) == length(ver2) && length(ver1) == 3)
     ismaster1 = isnan(str2double(ver1{3}));
     ismaster2 = isnan(str2double(ver2{3}));
     if (maj_ver1 == maj_ver2) && (min_ver1 == min_ver2) && (ismaster1 && ~ismaster2)
-        return;
+        return
     end
 
     if ~ismaster1 && ~ismaster2
         rev_ver1 = str2double(ver1{3});
         rev_ver2 = str2double(ver2{3});
         if (maj_ver1 == maj_ver2) && (min_ver1 == min_ver2) && (rev_ver1 > rev_ver2)
-            return;
+            return
         end
     end
 end
diff --git a/matlab/ver_less_than.m b/matlab/ver_less_than.m
index e953ed8a2..d67ad82ff 100644
--- a/matlab/ver_less_than.m
+++ b/matlab/ver_less_than.m
@@ -36,27 +36,27 @@ ver2 = strsplit(ver2, {'.', '-'});
 maj_ver1 = str2double(ver1{1});
 maj_ver2 = str2double(ver2{1});
 if maj_ver1 < maj_ver2
-    return;
+    return
 end
 
 min_ver1 = str2double(ver1{2});
 min_ver2 = str2double(ver2{2});
 if (maj_ver1 == maj_ver2) && (min_ver1 < min_ver2)
-    return;
+    return
 end
 
 if (length(ver1) == length(ver2) && length(ver1) == 3)
     ismaster1 = isnan(str2double(ver1{3}));
     ismaster2 = isnan(str2double(ver2{3}));
     if (maj_ver1 == maj_ver2) && (min_ver1 == min_ver2) && (~ismaster1 && ismaster2)
-        return;
+        return
     end
 
     if ~ismaster1 && ~ismaster2
         rev_ver1 = str2double(ver1{3});
         rev_ver2 = str2double(ver2{3});
         if (maj_ver1 == maj_ver2) && (min_ver1 == min_ver2) && (rev_ver1 < rev_ver2)
-            return;
+            return
         end
     end
 end
diff --git a/matlab/write_latex_parameter_table.m b/matlab/write_latex_parameter_table.m
index c2d739801..423d00128 100644
--- a/matlab/write_latex_parameter_table.m
+++ b/matlab/write_latex_parameter_table.m
@@ -29,7 +29,7 @@ function write_latex_parameter_table
 % 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_;
+global M_
 
 if ~isequal(M_.param_names,M_.param_names_long)
     Long_names_present=1;
@@ -38,7 +38,7 @@ else
 end
 fid = fopen([M_.fname '_latex_parameters.tex'], 'w');
 fprintf(fid, '\\begin{center}\n');
-if Long_names_present==1;
+if Long_names_present==1
     fprintf(fid, '\\begin{longtable}{ccc}\n');
 else
     fprintf(fid, '\\begin{longtable}{cc}\n');
@@ -48,7 +48,7 @@ fprintf(fid, ['\\caption{Parameter Values}\\\\%%\n']);
 fprintf(fid, '\\toprule%%\n');
 fprintf(fid, '\\multicolumn{1}{c}{\\textbf{Parameter}} &\n');
 fprintf(fid, '\\multicolumn{1}{c}{\\textbf{Value}} ');
-if Long_names_present==1;
+if Long_names_present==1
     fprintf(fid, '&\n \\multicolumn{1}{c}{\\textbf{Description}}\\\\%%\n');
 else
     fprintf(fid, ' \\\\%%\n');
@@ -56,7 +56,7 @@ end
 fprintf(fid, '\\midrule%%\n');
 fprintf(fid, '\\endfirsthead\n');
 
-if Long_names_present==1;
+if Long_names_present==1
     fprintf(fid, '\\multicolumn{3}{c}{{\\tablename} \\thetable{} -- Continued}\\\\%%\n');
 else
     fprintf(fid, '\\multicolumn{2}{c}{{\\tablename} \\thetable{} -- Continued}\\\\%%\n');
@@ -64,7 +64,7 @@ end
 fprintf(fid, '\\midrule%%\n');
 fprintf(fid, '\\multicolumn{1}{c}{\\textbf{Parameter}} &\n');
 fprintf(fid, '\\multicolumn{1}{c}{\\textbf{Value}} ');
-if Long_names_present==1;
+if Long_names_present==1
     fprintf(fid, '&\n  \\multicolumn{1}{c}{\\textbf{Description}}\\\\%%\n');
 else
     fprintf(fid, '\\\\%%\n');
@@ -75,7 +75,7 @@ fprintf(fid, '\\endhead\n');
 tex = M_.param_names_tex;
 long = M_.param_names_long;
 for j=1:size(tex,1)
-if Long_names_present==1;
+if Long_names_present==1
     % replace underscores
     long_names_temp=regexprep(strtrim(long(j,:)), '_', '\\_');
     % replace percent
diff --git a/matlab/writedata_text.m b/matlab/writedata_text.m
index 5af543e9c..9def1a107 100644
--- a/matlab/writedata_text.m
+++ b/matlab/writedata_text.m
@@ -32,7 +32,7 @@ S=[fname '_endo.dat'];
 fid = fopen(S,'w');
 for i = 1:size(M_.endo_names,1)
     fprintf(fid,'%s ',M_.endo_names(i,:)');
-end;
+end
 fprintf(fid,'\n');
 for i = 1:size(oo_.endo_simul,2)
     fprintf(fid,'%15.7f ',oo_.endo_simul(:,i));
@@ -44,11 +44,10 @@ S=[fname '_exo.dat'];
 fid = fopen(S,'w');
 for i = 1:size(M_.exo_names,1)
     fprintf(fid,'%s ',M_.exo_names(i,:));
-end;
+end
 fprintf(fid,'\n');
 for i = 1:size(oo_.exo_simul,1)
     fprintf(fid,'%15.7f ',oo_.exo_simul(i,:));
     fprintf(fid,'\n');
 end
-fclose(fid);
-return;
\ No newline at end of file
+fclose(fid);
\ No newline at end of file
-- 
GitLab