Fix a state change bug.