Replaced prevMenu and cachedState with prevState.