diff --git a/matlab/csminwel1.m b/matlab/csminwel1.m
index 4981da01d..e53a852a9 100644
--- a/matlab/csminwel1.m
+++ b/matlab/csminwel1.m
@@ -40,7 +40,7 @@ function [fh,xh,gh,H,itct,fcount,retcodeh] = csminwel1(fcn,x0,H0,grad,crit,nit,m
% You should have received a copy of the GNU General Public License
% along with Dynare. If not, see .
-global bayestopt_
+% global bayestopt_
fh = [];
xh = [];
@@ -91,7 +91,7 @@ f=f0;
H=H0;
cliff=0;
while ~done
- bayestopt_.penalty = f;
+ varargin{5}.penalty = f;
g1=[]; g2=[]; g3=[];
%addition fj. 7/6/94 for control
disp('-----------------')
diff --git a/matlab/newrat.m b/matlab/newrat.m
index 19f1d7e0e..8edaff6af 100644
--- a/matlab/newrat.m
+++ b/matlab/newrat.m
@@ -106,7 +106,7 @@ while norm(gg)>gtol && check==0 && jit