Moved training "code" to a new file