Fix an infinite loop at OnSave