(io_lib r3470)
Fixed re-calling refs2id so it clears cached r->last; the pointer
becomes invalid.

Also fixed debugging information to avoid assumptions on how pointer
differencing works when both pointers aren't from the same allocated
memory block.