Beware of modifying a list being iterated

Change-Id: Ib9cf1a47eb20bd28d954ddcded89f67cf6865f1c