Adding gameLoop, and refactoring