Cleaned up state management a little.

Now it makes more sense to me.