Fixes to mode_compute=5. (1) force univariate steps at every iteration: ...

...improve robustness at the expenses of a bit less efficiency; (2) fix gradient computation for special cases when the value of the parameters get stacked at the prior boundary.

(cherry picked from commit e5854cb2014c0906bd1d797f251547b77fc415aa)