refactor and clean up gamestate