Fixed a crash that occurs when trying to delete an object.