Fixed bug with deleting objects using iterator