       (cond
         (and (even? numparams)
              (keyword? (first params))
-             (satisfies? ISpecType (second params)))
+             (satisfies? ISpec (second params)))
         :associative
 
-        (every? #(satisfies? ISpecType %) params)
+        (every? #(satisfies? ISpec %) params)
         :indexed))))
 
 (defmethod spec :associative

                   (rest types)))
          [(- index pos) result])))

    IWritableSpec
    (write [_ buff pos data']
      (let [indexedtypes (map-indexed vector types)
            written (reduce (fn [pos [index type]]

              (clojure.core/byte 1) true
              nil)]))

     (write [_ buff pos value]
       (let [value (condp = value
                     true (clojure.core/byte 1)
                     false (clojure.core/byte 0)
                     (clojure.core/byte -1))]
         (buffer/write-byte buff pos value)
         1)))))

(defn byte
  "Byte type spec constructor."
  ([] (byte (clojure.core/byte 0)))
  ([default]
   (reify
     IStaticSize
     (size [_] 1)

     ISpec
     (read [_ buff pos]
       (let [readed (buffer/read-byte buff pos)]
         [1 readed]))

     (write [_ buff pos value]
       (let [value (clojure.core/byte (or value default))]
         (buffer/write-byte buff pos value)
         1)))))

(defn int16
  "Short type spec constructor."
  ([] (int16 0))
  ([default]
   (reify
     IStaticSize
     (size [_] (Short/BYTES))

     ISpec
     (read [_ buff pos]
       [(Short/BYTES)
        (buffer/read-short buff pos)])

     (write [_ buff pos value]
       (let [value (or value default)]
         (buffer/write-short buff pos value)
         (Short/BYTES))))))


(defn int32
  "Integer type spec constructor."
  ([] (int32 0))
  ([default]
   (reify
     IStaticSize
     (size [_] (Integer/BYTES))

     ISpec
     (read [_ buff pos]
       [(Integer/BYTES)
        (buffer/read-int buff pos)])

     (write [_ buff pos value]
       (let [value (or value default)]
         (buffer/write-int buff pos value)
         (Integer/BYTES))))))

(defn int64
  "Long type spec constructor."
  ([] (int64 0))
  ([default]
   (reify
     IStaticSize
     (size [_] (Long/BYTES))

     ISpec
     (read [_ buff pos]
       [(Long/BYTES)
        (buffer/read-long buff pos)])

     (write [_ buff pos value]
       (let [value (or value default)]
         (buffer/write-long buff pos value)
         (Long/BYTES))))))

(defn real32
  "Float type spec constructor."
  ([] (real32 0))
  ([default]
   (reify
     IStaticSize
     (size [_] (Float/BYTES))

     ISpec
     (read [_ buff pos]
       [(Float/BYTES)
        (buffer/read-float buff pos)])

     (write [_ buff pos value]
       (let [value (or value default)]
         (buffer/write-float buff pos value)
         (Float/BYTES))))))

(defn real64
  "Double type spec constructor."
  ([] (real64 0))
  ([default]
   (reify
     IStaticSize
     (size [_] (Double/BYTES))

     ISpec
     (read [_ buff pos]
       [(Double/BYTES)
        (buffer/read-double buff pos)])

     (write [_ buff pos value]
       (let [value (or value default)]
         (buffer/write-double buff pos value)
         (Double/BYTES))))))

(defn string
  "Fixed size string type spec constructor."
  [^long size]
  (reify
    IStaticSize
    (size [_] size)

    ISpec
    (read [_ buff pos]
      (let [rawdata (buffer/read-bytes buff pos size)
            length  (- size (bytes/zeropad-count rawdata))
            data (String. rawdata 0 length "UTF-8")]
        [size data]))

    (write [_ buff pos value]
      (let [input (.getBytes value "UTF-8")
            length (count input)
