refactoring the game engine w/memory management