Added the afterSave callback
Making save atomic