Make FREEZE/THAW respect referential integrity.

This restores the FREEZE/THAW semantics so that RI is maintained.

In particular we need to certain checks against the ORIGINAL referent
of an object, and only later, once those checks have failed, use the
replacement.

This is made quite a bit more awkward than it needs to be by making
FREEZE/THAW *require* that *objects* are output *always*. And means that
we have little choice but to make

  sub FREEZE { \"FOO" }

be the same as

  sub FREEZE { "FOO" }

As the frozen object replaces the *referent* not the *reference*.

IMO this could be simplified by making the FREEZE hook more generic.