Fixes to gradient/objective