Some state machine fixes.