Refactoring, breaking up main engine file