Refactored train mode code a little.