Safely restore state