int serialisePair( byte[] bytes, int p, int setSize, int dataOffset, 
		int dataTableOffset, int parentId ) throws MVDException
	{
		try
        {
            int oldP = p;
            int flag = 0;
            if ( parent != null )
                flag = CHILD_FLAG;
            else if ( children != null )
                flag = PARENT_FLAG;
            if ( bytes.length > p + pairSize(setSize) )
            {
                p += serialiseVersions( bytes, p, setSize );
                // write data offset
                // can't see the point of this any more
                //writeInt( bytes, p, (children==null)?dataOffset:-dataOffset );
                writeInt( bytes, p, dataOffset );
                p += 4;
                // write data length ORed with the parent/child flag
                int dataLength = (data==null)?0:this.byteLength(); 
                dataLength |= flag;
                writeInt( bytes, p, dataLength );
                p += 4;
                if ( parentId != MVD.NULL_PID )
                {
                    writeInt( bytes, p, parentId );
                    p += 4;
                }
                // write actual data
                if ( parent == null && !isHint() )
                    p += writeData( bytes, dataTableOffset+dataOffset, getData() );
            }
            else
                throw new Exception( "No room for pair during serialisation" );
            return p - oldP;
        }
        catch ( Exception e )
        {
            throw new MVDException(e);
        }
	}