Add destruction of iterators to avoid problems with refcounters