Debug array iterations which may crash

These two iterations over listeners may crash if an element is removed from the array, so that's why I am changing one to be done in reversed order and the othe over a copy of the array,