Add "state" config option. Moved optional state handlers to state key object