Sorry for coming back to this a bit late. I'll probably add the code you submitted to RDNZL anyway as it might turn out to be useful in specific cases, but note that there's a "portable" way to solve your problem. Simply replace this line
(if (pointers-equal x [%reference x])
with
(if [Equals x [%reference x]]
That should do the trick.
Cheers, Edi.