Which version are you using? It's a bit odd iterating over the instances and then setting the instHeader on each instance - the instHeader is common to all instances of the same type - so setting it once will set all instances in one shot. So you'd iterate over cvId~>instHeaders and then change them once.
If you want to set each instance separately, you'd set the master attribute on the instance - and the instHeaders will take care of themselves.
So setting the instHeader master is a very quick way to change all instances of a lib/cell/view to a different lib/cell/view in one go.
That said, I tried doing what you were doing in IC615, and couldn't reproduce the problem (but as I said, it's a bit of an odd way of doing things anyway).