Fix bug with PackWithReplacements when replacing top-level object with complex values.

Basically, make this work:

```
A = {NewCell 1}
_ = {PackWithReplacments A [A#(a(b))]}
```

Current it fails with "Resources found during pickling", because a Reference is generated during replacement, and pickle.cc was not handling this.