This stuff gets tricky sometimes, because if there are existing 'invalids' some operations, like Replace, may not necessarily cleanly overwrite stuff that is seen as 'invalid'. I would try Remove(invalid connections) followed by Replace(new invalid connections).
On Wednesday, Jul 2, 2003, at
Chris is right about messing with invalids being a tricky process. He gave me
quite useful help long ago. But even now after years of tinkering, I still
stumble across surprising results, things I didn't know, and cases that break
my algorithm (i.e. it was proven to work only most of the time).