Introduce state.mode (Refactoring #1)