Refactored part of the game engine.