Bag and BagIterator refactoring