GameState implementation

Implemented method for gamestates, with comments to explain how it
works.