State management redone.

State manager is now a state.