Fixed bugs with iterators