Restore and save UI state