Started porting the main game loop