More fixes to training code