Extract train functionality to own class

Signed-off-by: Darkrulerz <Dark_rulerz@hotmail.com>