Moving main routine

Moved the main routine logic into the core class.