Add configurable state handlers (setState, removeState, getState)

Couldn't get unit tests to work. 
I hope this works for you.