fix minor bugs in StateManager