Remember and correctly handle the state between popups