Fix iterator issue in listeners