Fix possible ConcurrentModificationException problems.