Refactored game code.