Working Statemanager

And some other stuff.