Fix crash that was caused by deleting elements from a vector while iterating over it