Fix bug in train.