Fix a potential issue with removing orphan blocks.

The range loop is over a local var, so the local variable needs to be
updated and then set back into the chain instance after the range loop.