Implemented save/restore of state to local storage