Minor state management refactoring
Currently, the swapStates() function does two things - (a) it merges one state with another; (b) it applies the next state. This change splits the swapStates() so it's simpler and the boolean trap can be removed.
Currently, the swapStates() function does two things - (a) it merges one state with another; (b) it applies the next state. This change splits the swapStates() so it's simpler and the boolean trap can be removed.