Changes to fix some issues for recording state in several scenarios.