Fixes to apply_gradient
related to issue #388
#391
+11
−3
Merged