Reduce js load by only calling functions when the gamestate changes