Crash fix: Don't mutate array while iterating