Move engine code to it's own file