Fix InvalidOperationException due to modified collection