Fix "collection cannot be iterated after modification" error when event handler cancels/subscribes to events.