Fixed bug with deleting while iterating.

Hit on this bug, so I fixed it.  Didn't search the rest of the code for similar problems.