Finished save/restore function