Improved the organization of the training method.