Fix bugs in stateManager. Modes were mixed up