added encoding/decoding of referents