Saving and restoring state when quit and start again