Fixes possible ConcurrentModificationException.