Fixed bugs in NDIterator