Fix for issue #674: generate an index set of the elements to remove and remove those indexes directly.