Adding more robust enumeration handling.

We keep getting an exception around modifying the enumerable
while iterating. This should either fix it or narrow it down.