Added states and a game loop.