Added global procedures encodeNeighbor and decodeNeighbor
Refactored client/server share code to use these procedures