Added some missing steps in the saving and restoring.