Fix ConcurrentModificationError by moving the copy+clear of updatedVMs list inside the lock