diff --git a/matlab/PosteriorIRF_core1.m b/matlab/PosteriorIRF_core1.m
index f9143a3a1e842ea99fa417865999505da03b94b5..82c5cfab9ada0d5bf8dd380ca81822779b3376ba 100644
--- a/matlab/PosteriorIRF_core1.m
+++ b/matlab/PosteriorIRF_core1.m
@@ -23,7 +23,7 @@ function myoutput=PosteriorIRF_core1(myinputs,fpar,B,whoiam, ThisMatlab)
 % SPECIAL REQUIREMENTS.
 %   None.
 %
-% Copyright (C) 2006-2018 Dynare Team
+% Copyright (C) 2006-2019 Dynare Team
 %
 % This file is part of Dynare.
 %
@@ -70,10 +70,8 @@ NumberOfIRFfiles_dsgevar=myinputs.NumberOfIRFfiles_dsgevar;
 ifil2=myinputs.ifil2;
 
 if options_.dsge_var
-    gend=myinputs.gend;
     nvobs=myinputs.nvobs;
     NumberOfParametersPerEquation = myinputs.NumberOfParametersPerEquation;
-    NumberOfLags = myinputs.NumberOfLags;
     NumberOfLagsTimesNvobs = myinputs.NumberOfLagsTimesNvobs;
     Companion_matrix = myinputs.Companion_matrix;
     stock_irf_bvardsge = zeros(options_.irf,nvobs,M_.exo_nbr,MAX_nirfs_dsgevar);
@@ -194,7 +192,7 @@ while fpar<B
     end
     if MAX_nirfs_dsgevar
         IRUN = IRUN+1;
-        [fval,info,~,~,~,~,~,PHI,SIGMAu,iXX] =  dsge_var_likelihood(deep',dataset_,dataset_info,options_,M_,estim_params_,bayestopt_,bounds,oo_);
+        [~,~,~,~,~,~,~,PHI,SIGMAu,iXX] =  dsge_var_likelihood(deep',dataset_,dataset_info,options_,M_,estim_params_,bayestopt_,bounds,oo_);
         dsge_prior_weight = M_.params(strmatch('dsge_prior_weight', M_.param_names));
         DSGE_PRIOR_WEIGHT = floor(dataset_.nobs*(1+dsge_prior_weight));
         SIGMA_inv_upper_chol = chol(inv(SIGMAu*dataset_.nobs*(dsge_prior_weight+1)));
@@ -216,7 +214,7 @@ while fpar<B
         if dsge_prior_weight > 0
             Atheta(oo_.dr.order_var,M_.exo_names_orig_ord) = oo_.dr.ghu*sqrt(M_.Sigma_e);
             A0 = Atheta(bayestopt_.mfys,:);
-            [OMEGAstar,SIGMAtr] = qr2(A0');
+            OMEGAstar = qr2(A0');
         end
         SIGMAu_chol = chol(SIGMAu_draw)';
         SIGMAtrOMEGA = SIGMAu_chol*OMEGAstar';
@@ -245,7 +243,6 @@ while fpar<B
             end
             NumberOfIRFfiles_dsgevar = NumberOfIRFfiles_dsgevar+1;
             IRUN =0;
-            stock_irf_dsgevar = zeros(options_.irf,dataset_.vobs,M_.exo_nbr,MAX_nirfs_dsgevar);
         end
     end
     if irun == MAX_nirfs_dsge || irun == B || fpar == B
diff --git a/matlab/discretionary_policy.m b/matlab/discretionary_policy.m
index d14f4044a47cc6cd36eb372d4cf0ee61598d9242..c565353ce7813310db71200150f2ff00f27d7479 100644
--- a/matlab/discretionary_policy.m
+++ b/matlab/discretionary_policy.m
@@ -28,12 +28,11 @@ if ~options_.noprint
     disp_steady_state(M_,oo_)
     for i=M_.orig_endo_nbr:M_.endo_nbr
         if strmatch('mult_', M_.endo_names{i})
-            disp(sprintf('%s \t\t %g', M_.endo_names{i}, oo_.dr.ys(i)));
+            fprintf('%s \t\t %g\n', M_.endo_names{i}, oo_.dr.ys(i));
         end
     end
 end
 
-
 oo_.planner_objective_value = evaluate_planner_objective(M_,options_,oo_);
 
 options_ = oldoptions;
diff --git a/matlab/moment_function.m b/matlab/moment_function.m
index fb42db9e888f99380249493ab75abb258ac49226..8b922963a1ae3e818c42685bf867bbbd8af0909b 100644
--- a/matlab/moment_function.m
+++ b/matlab/moment_function.m
@@ -15,7 +15,7 @@ function [g,grad,hess,flag] = moment_function(xparams,sample_moments,dataset,opt
 % SPECIAL REQUIREMENTS
 %  The user has to provide a file where the moment conditions are defined.
 
-% Copyright (C) 2010-2017 Dynare Team
+% Copyright (C) 2010-2019 Dynare Team
 %
 % This file is part of Dynare.
 %
@@ -92,7 +92,7 @@ else% parallel mode.
         error('The parallel version of SMM estimation is not implemented for non unix platforms!')
     end
     job_number = 1;% Remark. First job is for the master.
-    [Junk,hostname] = unix('hostname --fqdn');
+    [~,hostname] = unix('hostname --fqdn');
     hostname = deblank(hostname);
     for i=1:length(parallel)
         machine = deblank(parallel(i).machine);
diff --git a/matlab/osr1.m b/matlab/osr1.m
index 1f7037e12d526b27d38ed8ac05775cf19b0f82f9..8300daa9a9903db05ffb348cfb7aca5016db7c35 100644
--- a/matlab/osr1.m
+++ b/matlab/osr1.m
@@ -16,7 +16,7 @@ function osr_res = osr1(i_params,i_var,weights)
 %   Uses Newton-type optimizer csminwel to directly solve quadratic
 %   osr-problem
 %
-% Copyright (C) 2005-2018 Dynare Team
+% Copyright (C) 2005-2019 Dynare Team
 %
 % This file is part of Dynare.
 %
@@ -35,10 +35,6 @@ function osr_res = osr1(i_params,i_var,weights)
 
 global M_ oo_ options_ it_
 
-klen = M_.maximum_lag + M_.maximum_lead + 1;
-iyv = M_.lead_lag_incidence';
-iyv = iyv(:);
-iyr0 = find(iyv) ;
 it_ = M_.maximum_lag + 1 ;
 
 osr_res.error_indicator = 1; %initialize indicator
@@ -84,8 +80,6 @@ if isfield(options_.osr,'maxit') || isfield(options_.osr,'tolf')
     end
 end
 
-exe =zeros(M_.exo_nbr,1);
-
 oo_.dr = set_state_space(oo_.dr,M_,options_);
 
 
@@ -99,7 +93,7 @@ inv_order_var = oo_.dr.inv_order_var;
 %extract unique entries of covariance
 i_var=unique(i_var);
 %% do initial checks
-[loss,info,exit_flag,vx]=osr_obj(t0,i_params,inv_order_var(i_var),weights(i_var,i_var));
+[loss,info]=osr_obj(t0,i_params,inv_order_var(i_var),weights(i_var,i_var));
 if info~=0
     print_info(info, options_.noprint, options_);
 else
@@ -129,7 +123,7 @@ else
         error('OSR: OSR with bounds on parameters requires a constrained optimizer, i.e. opt_algo= 1,2,5, or 9.')
     end
     %%do actual optimization
-    [p, f, exitflag] = dynare_minimize_objective(str2func('osr_obj'),t0,options_.osr.opt_algo,options_,M_.osr.param_bounds,M_.param_names(i_params),[],[], i_params,...
+    [p, f] = dynare_minimize_objective(str2func('osr_obj'),t0,options_.osr.opt_algo,options_,M_.osr.param_bounds,M_.param_names(i_params),[],[], i_params,...
                                                  inv_order_var(i_var),weights(i_var,i_var));
 end
 
@@ -144,9 +138,9 @@ if ~options_.noprint
     disp('OPTIMAL VALUE OF THE PARAMETERS:')
     skipline()
     for i=1:np
-        disp(sprintf('%16s %16.6g\n', M_.param_names{i_params(i)}, p(i)))
+        fprintf('%16s %16.6g\n\n', M_.param_names{i_params(i)}, p(i));
     end
-    disp(sprintf('Objective function : %16.6g\n',f));
+    fprintf('Objective function : %16.6g\n\n',f);
     skipline()
 end
 [oo_.dr,info,M_,options_,oo_] = resol(0,M_,options_,oo_);
diff --git a/matlab/smm_objective.m b/matlab/smm_objective.m
index fc6358205c484e169e557c6fd74e597e70e2015e..9ff0e338a88ccd0018c885085487cfe24accb47d 100644
--- a/matlab/smm_objective.m
+++ b/matlab/smm_objective.m
@@ -15,7 +15,7 @@ function [r,flag] = smm_objective(xparams,sample_moments,weighting_matrix,option
 % SPECIAL REQUIREMENTS
 %  The user has to provide a file where the moment conditions are defined.
 
-% Copyright (C) 2010-2017 Dynare Team
+% Copyright (C) 2010-2019 Dynare Team
 %
 % This file is part of Dynare.
 %
@@ -75,7 +75,7 @@ save('estimated_parameters.mat','xparams');
 
 % Check for local determinacy of the deterministic steady state.
 noprint = options_.noprint; options_.noprint = 1;
-[eigval,local_determinacy_and_stability,info] = check(M_,options_,oo_); options_.noprint = noprint;
+[~,local_determinacy_and_stability,info] = check(M_,options_,oo_); options_.noprint = noprint;
 if ~local_determinacy_and_stability
     r = priorObjectiveValue * (1+info(2));
     flag = 0;
@@ -100,7 +100,7 @@ else% parallel mode.
         error('The parallel version of SMM estimation is not implemented for non unix platforms!')
     end
     job_number = 1;% Remark. First job is for the master.
-    [Junk,hostname] = unix('hostname --fqdn');
+    [~,hostname] = unix('hostname --fqdn');
     hostname = deblank(hostname);
     for i=1:length(parallel)
         machine = deblank(parallel(i).machine);