Refactoring client and server, improving game state machine