Update to gamestate to call leave outside of the loop switch was called

See issue #15--This solves a problem I was having with cleanup by waiting until the next state function is called before calling leave.

It also handles the case where you call Gamestate.switch multiple times in the same loop by cleaning up the middle gamestate immediately.

The only problem I see with this is that it changes the order in which the functions are called--init and enter are called immediately so that enter can return the value, and leave is called after. This isn't a huge problem, as far as I can tell.