Fixed bug in deleting objects