Little refactoring.
Fixed connection fail at the game end.