Saving and restoring application status