                        [(conj state (take n data))
                         (drop n data)])))
           (ffilter (comp empty? second))
-          first (apply concat) byte-array))
+          first (drop 1) (apply concat) byte-array))
   ([wire ^long offset ^long length]
      (wire->bytes (->> wire (drop offset) (take length)))))
 

  [domain] (->> (iterate #(domain-next domain %) nil) (drop 1)
                (take-while identity)))

(deftype DNSDomain [^IPersistentMap meta, ^bytes bytes, ^long length]
  Object
  (toString [this] (bytes->name bytes 0 length))
  (hashCode [this] (bytes-hash-code bytes 0 length))
  (equals [this other]
    (and (domain? other)
         (= length (domain-length other))
         (Arrays/equals bytes ^bytes (domain-bytes other))))

  IObj
  (meta [this] meta)
  (withMeta [this new-meta] (DNSDomain. new-meta bytes length))

  Comparable
  (compareTo [this other]
    (domain-compare true this other))

  ILookup
  (valAt [this key]
    (when (domain-contains? this key) key))
  (valAt [this key default]
    (if (domain-contains? this key) key default))

  IFn
  (invoke [this key]
    (when (domain-contains? this key) key))
  (invoke [this key default]
    (if (domain-contains? this key) key default))

  DNSDomainConstruction
  (domain [this] this)

  DNSDomainOperations
  (domain?* [this] true)
  (domain-bytes [this] bytes)
  (domain-length [this] length))

(def ^:private root-domain
  "The singleton empty root domain."
  (DNSDomain. nil (byte-array []) 0))

(defn- domain*
  [orig ^bytes bytes]
  (if (domain?* bytes)
    (DNSDomain. nil bytes (alength bytes))
    (domain-error "%s: invalid domain" (str orig))))

(extend-type (java.lang.Class/forName "[B")
  DNSDomainConstruction
  (domain [this] (domain* this this))

  ([bytes ^long offset ^long length]
     (bytes->name (->> bytes (drop offset) (take length)))))

(deftype DNSDomain [^IPersistentMap meta, ^bytes bytes, ^long length]
  Object
  (toString [this] (bytes->name bytes 0 length))
  (hashCode [this] (bytes-hash-code bytes 0 length))
  (equals [this other]
    (and (domain? other)
         (= length (domain-length other))
         (Arrays/equals bytes ^bytes (domain-bytes other))))

  IObj
  (meta [this] meta)
  (withMeta [this new-meta] (DNSDomain. new-meta bytes length))

  Comparable
  (compareTo [this other]
    (domain-compare true this other))

  ILookup
  (valAt [this key]
    (when (domain-contains? this key) key))
  (valAt [this key default]
    (if (domain-contains? this key) key default))

  IFn
  (invoke [this key]
    (when (domain-contains? this key) key))
  (invoke [this key default]
    (if (domain-contains? this key) key default))

  DNSDomainConstruction
  (domain [this] this)

  DNSDomainOperations
  (domain?* [this] true)
  (domain-bytes [this] bytes)
  (domain-length [this] length))

(def ^:private root-domain
  "The singleton empty root domain."
  (DNSDomain. nil (byte-array []) 0))

(defn- domain*
  [orig ^bytes bytes]
  (if (domain?* bytes)
    (DNSDomain. nil bytes (alength bytes))
    (domain-error "%s: invalid domain" (str orig))))

(defn domain-next
  "For the domain child which is a subdomain of domain parent, return the
immediate child domain of parent which is either identical to child or also a
