Refactored training logic into a seperate file, modified other files to match