add state event hooks. Resolves #22