I have code around to avoid keeping invalidated iterator, please check the removing_events_ .