Refactoring game logic.