Fixed some bugs in state machines.
Release.