Adding code for auto-save.