Fix crash when deleting