diff --git a/matlab/AIM_first_order_solver.m b/matlab/AIM_first_order_solver.m
index 82e6ddfbfaa954a8b391a7fba67d106288d77a70..0b9891fe57f6bdf70d02678e5e0202667ef389b0 100644
--- a/matlab/AIM_first_order_solver.m
+++ b/matlab/AIM_first_order_solver.m
@@ -1,4 +1,88 @@
-function [dr,info]=AIM_first_order_solver(jacobia,M,dr,qz_criterium,nd)
+function [dr,info]=AIM_first_order_solver(jacobia,M,dr,qz_criterium)
+
+%@info:
+%! @deftypefn {Function File} {[@var{dr},@var{info}] =} AIM_first_order_solver (@var{jacobia},@var{M},@var{dr},@var{qz_criterium})
+%! @anchor{AIM_first_order_solver}
+%! @sp 1
+%! Computes the first order reduced form of the DSGE model using AIM.
+%! @sp 2
+%! @strong{Inputs}
+%! @sp 1
+%! @table @ @var
+%! @item jacobia
+%! Matrix containing the Jacobian of the model
+%! @item M
+%! Matlab's structure describing the model (initialized by @code{dynare}).
+%! @item dr
+%! Matlab's structure describing the reduced form solution of the model.
+%! @item qz_criterium
+%! Double containing the criterium to separate explosive from stable eigenvalues
+%! @end table
+%! @sp 2
+%! @strong{Outputs}
+%! @sp 1
+%! @table @ @var
+%! @item dr
+%! Matlab's structure describing the reduced form solution of the model.
+%! @item info
+%! Integer scalar, error code.
+%! @sp 1
+%! @table @ @code
+%! @item info==0
+%! No error.
+      case 102
+        error('Aim: roots not correctly computed by real_schur');
+      case 103
+        error('Aim: too many big roots');
+      case 135
+        error('Aim: too many big roots, and q(:,right) is singular');
+      case 104
+        error('Aim: too few big roots');
+      case 145
+        error('Aim: too few big roots, and q(:,right) is singular');
+      case 105
+        error('Aim: q(:,right) is singular');
+      case 161
+        error('Aim: too many exact shiftrights');
+      case 162
+        error('Aim: too many numeric shiftrights');
+
+%! @item info==102
+%! roots not correctly computed by real_schur
+%! @item info==103
+%! Blanchard & Kahn conditions are not satisfied: no stable equilibrium.
+%! @item info==104
+%! Blanchard & Kahn conditions are not satisfied: indeterminacy.
+%! @item info==135
+%! too many explosive roots and q(:,right) is singular
+%! @item info==145
+%! too few big roots, and q(:,right) is singular
+%! @item info==105
+%! q(:,right) is singular
+%! @item info==161
+%! too many exact siftrights
+%! @item info==162
+%! too many numeric shiftrights
+%! @end table
+%! @end deftypefn
+%@eod:
+
+% Copyright (C) 2001-2011 Dynare Team
+%
+% This file is part of Dynare.
+%
+% Dynare is free software: you can redistribute it and/or modify
+% it under the terms of the GNU General Public License as published by
+% the Free Software Foundation, either version 3 of the License, or
+% (at your option) any later version.
+%
+% Dynare is distributed in the hope that it will be useful,
+% but WITHOUT ANY WARRANTY; without even the implied warranty of
+% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+% GNU General Public License for more details.
+%
+% You should have received a copy of the GNU General Public License
+% along with Dynare.  If not, see <http://www.gnu.org/licenses/>.
     
     info = 0;
     
diff --git a/matlab/dyn_risky_steadystate_solver.m b/matlab/dyn_risky_steadystate_solver.m
index d32663cb7a6c536be41545599c67016dc7032cda..8324193846065fc8ef9725838a1c7c50beb91dce 100644
--- a/matlab/dyn_risky_steadystate_solver.m
+++ b/matlab/dyn_risky_steadystate_solver.m
@@ -1,5 +1,85 @@
 function [dr,info] = dyn_risky_steadystate_solver(ys0,M, ...
                                                   dr,options,oo)
+
+%@info:
+%! @deftypefn {Function File} {[@var{dr},@var{info}] =} dyn_risky_steadystate_solver (@var{ys0},@var{M},@var{dr},@var{options},@var{oo})
+%! @anchor{dyn_risky_steadystate_solver}
+%! @sp 1
+%! Computes the second order risky steady state and first and second order reduced form of the DSGE model.
+%! @sp 2
+%! @strong{Inputs}
+%! @sp 1
+%! @table @ @var
+%! @item ys0
+%! Vector containing a guess value for the risky steady state
+%! @item M
+%! Matlab's structure describing the model (initialized by @code{dynare}).
+%! @item dr
+%! Matlab's structure describing the reduced form solution of the model.
+%! @item options
+%! Matlab's structure describing the options (initialized by @code{dynare}).
+%! @item oo
+%! Matlab's structure gathering the results (initialized by @code{dynare}).
+%! @end table
+%! @sp 2
+%! @strong{Outputs}
+%! @sp 1
+%! @table @ @var
+%! @item dr
+%! Matlab's structure describing the reduced form solution of the model.
+%! @item info
+%! Integer scalar, error code.
+%! @sp 1
+%! @table @ @code
+%! @item info==0
+%! No error.
+%! @item info==1
+%! The model doesn't determine the current variables uniquely.
+%! @item info==2
+%! MJDGGES returned an error code.
+%! @item info==3
+%! Blanchard & Kahn conditions are not satisfied: no stable equilibrium.
+%! @item info==4
+%! Blanchard & Kahn conditions are not satisfied: indeterminacy.
+%! @item info==5
+%! Blanchard & Kahn conditions are not satisfied: indeterminacy due to rank failure.
+%! @item info==6
+%! The jacobian evaluated at the deterministic steady state is complex.
+%! @item info==19
+%! The steadystate routine thrown an exception (inconsistent deep parameters).
+%! @item info==20
+%! Cannot find the steady state, info(2) contains the sum of square residuals (of the static equations).
+%! @item info==21
+%! The steady state is complex, info(2) contains the sum of square of imaginary parts of the steady state.
+%! @item info==22
+%! The steady has NaNs.
+%! @item info==23
+%! M_.params has been updated in the steadystate routine and has complex valued scalars.
+%! @item info==24
+%! M_.params has been updated in the steadystate routine and has some NaNs.
+%! @item info==30
+%! Ergodic variance can't be computed.
+%! @end table
+%! @end deftypefn
+%@eod:
+
+% Copyright (C) 2001-2011 Dynare Team
+%
+% This file is part of Dynare.
+%
+% Dynare is free software: you can redistribute it and/or modify
+% it under the terms of the GNU General Public License as published by
+% the Free Software Foundation, either version 3 of the License, or
+% (at your option) any later version.
+%
+% Dynare is distributed in the hope that it will be useful,
+% but WITHOUT ANY WARRANTY; without even the implied warranty of
+% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+% GNU General Public License for more details.
+%
+% You should have received a copy of the GNU General Public License
+% along with Dynare.  If not, see <http://www.gnu.org/licenses/>.
+
     
     info = 0;
     lead_lag_incidence = M.lead_lag_incidence;
diff --git a/matlab/resol.m b/matlab/resol.m
index 39954d7040d170099ae2bc8650eaf31779863052..c6be875156d8b154999700697e5b7e2f8c807f47 100644
--- a/matlab/resol.m
+++ b/matlab/resol.m
@@ -114,11 +114,7 @@ end
 if options.block
     [dr,info,M,options,oo] = dr_block(dr,check_flag,M,options,oo);
 else
-    dr.fbias = zeros(M.endo_nbr,1);
-    [dr,info,M,options,oo] = stochastic_solvers(dr,check_flag,M,options,oo);
+    [dr,info,oo] = stochastic_solvers(dr,check_flag,M,options,oo);
 end
 
-if info(1)
-    return
-end
 
diff --git a/matlab/stoch_simul.m b/matlab/stoch_simul.m
index 7e3975599115f53270f3c740237143a43b1c636b..84c48c0f10db96acb14947dae252efd497627fc0 100644
--- a/matlab/stoch_simul.m
+++ b/matlab/stoch_simul.m
@@ -73,8 +73,7 @@ elseif options_.discretionary_policy
     end
     [oo_.dr,ys,info] = discretionary_policy_1(oo_,options_.instruments);
 else
-    [dr,info,M_,options_,oo_] = resol(0,M_,options_,oo_);
-    oo_.dr = dr;
+    [oo_.dr,info,M_,options_,oo_] = resol(0,M_,options_,oo_);
 end
 
 if info(1)
diff --git a/matlab/stochastic_solvers.m b/matlab/stochastic_solvers.m
index 97fe44fe559586728f978cff46e6c619ebaa694f..6f6c50995f07919178e71dba6e142b7ce8f0949a 100644
--- a/matlab/stochastic_solvers.m
+++ b/matlab/stochastic_solvers.m
@@ -1,4 +1,4 @@
-function [dr,info,M_,options_,oo_] = stochastic_solvers(dr,task,M_,options_,oo_)
+function [dr,info,oo_] = stochastic_solvers(dr,task,M_,options_,oo_)
 % function [dr,info,M_,options_,oo_] = stochastic_solvers(dr,task,M_,options_,oo_)
 % computes the reduced form solution of a rational expectation model (first or second order
 % approximation of the stochastic model around the deterministic steady state). 
@@ -21,9 +21,7 @@ function [dr,info,M_,options_,oo_] = stochastic_solvers(dr,task,M_,options_,oo_)
 %                                         indeterminacy.
 %                                 info=5: BK rank condition not satisfied.
 %                                 info=6: The jacobian matrix evaluated at the steady state is complex.        
-%   M_         [matlab structure]            
-%   options_   [matlab structure]
-%   oo_        [matlab structure]
+%   oo_        [matlab structure] Results
 %  
 % ALGORITHM
 %   ...
@@ -140,7 +138,6 @@ b(:,cols_b) = jacobia_(:,cols_j);
 
 if M_.maximum_endo_lead == 0
     % backward models: simplified code exist only at order == 1
-    % If required, use AIM solver if not check only
     if options_.order == 1
         [k1,junk,k2] = find(kstate(:,4));
         dr.ghx(:,k1) = -b\jacobia_(:,k2); 
@@ -161,9 +158,9 @@ if M_.maximum_endo_lead == 0
                'backward models'])
     end
 elseif M_.maximum_endo_lag == 0
-% purely forward model
-dr.ghx = [];
-dr.ghu = -b\jacobia_(:,nz+1:end);
+    % purely forward model
+    dr.ghx = [];
+    dr.ghu = -b\jacobia_(:,nz+1:end);
 elseif options_.risky_steadystate
     [dr,info] = dyn_risky_steadystate_solver(oo_.steady_state,M_,dr, ...
                                              options_,oo_);