Fix enumeration bug that modifies object array.