Added pre/post state handlers, but untested