Added resource- and statemanagement.

Also added a bunch of other stuff.