Added functionality for training.