CURATOR-131 use iterator.remove instead of foreach

When iterating over a collection, if we try to remove elements that
can lead to undefined behaviour. We should use an iterator and its
remove method to do this safely.
Merge branch 'CURATOR-131' of https://github.com/madrob/curator into CURATOR-131