Moved as much shared code as possible to game_shared.c