make TrainProgram work and fix warnings