   [dest source offset length]
   (loop [pos offset]
     (when-let [ch (aget source pos)]
-      (case (bit-shift-right ch 4)
-        (0 1 2 3 4 5 6 7)
-        (do
-          (.append dest (.fromCharCode js/String ch))
-          (recur (inc pos)))
-        (12 13)
-        (let [ch1 (aget source (inc pos))]
-          (do
-            (.append
-              dest
-              (.fromCharCode
-                js/String
-                (bit-or (bit-and ch1 0x3f) (bit-shift-left (bit-and ch 0x1f) 6))))
-            (recur (+ 2 pos))))
-        (14)
-        (let [ch1 (aget source (inc pos))
-              ch2 (aget source (+ 2 pos))]
-          (do
-            (.append
-              dest
-              (.fromCharCode
-                js/String
-                (bit-or
-                  (bit-and ch2 0x3f)
-                  (bit-shift-left (bit-and ch1 0x3f) 6)
-                  (bit-shift-left (bit-and ch 0x0f) 12))))
-            (recur (+ 3 pos))))
-        (throw (js/Error. (str "Invalid UTF Character (" ch ")")))))))
+      (let [bsch (bit-shift-right ch 4)]
+        (cond
+          (<= 0 bsch 7)
+          (do
+            (.append dest (.fromCharCode js/String ch))
+            (recur (inc pos)))
+          (<= 12 bsch 13)
+          (let [ch1 (aget source (inc pos))]
+            (do
+              (.append
+                dest
+                (.fromCharCode
+                  js/String
+                  (bit-or (bit-and ch1 0x3f) (bit-shift-left (bit-and ch 0x1f) 6))))
+              (recur (+ 2 pos))))
+          (== bsch 14)
+          (let [ch1 (aget source (inc pos))
+                ch2 (aget source (+ 2 pos))]
+            (do
+              (.append
+                dest
+                (.fromCharCode
+                  js/String
+                  (bit-or
+                    (bit-and ch2 0x3f)
+                    (bit-shift-left (bit-and ch1 0x3f) 6)
+                    (bit-shift-left (bit-and ch 0x0f) 12))))
+              (recur (+ 3 pos))))
+          :else
+          (throw (js/Error. (str "Invalid UTF Character (" ch ")"))))))))
 
 (defn read-string-buffer!
   "Reads a string from a byte array

            (bsp/reset! bis)
            (.clear-caches! bis)
            (p/read-object! bis)))
        ((.-FLOAT c/codes)) (bsp/read-float! bis)
        ((.-DOUBLE_0 c/codes)) 0.0
        ((.-DOUBLE_1 c/codes)) 1.0
        ((.-DOUBLE c/codes)) (bsp/read-double! bis))))
  (validate-footer! [bis]
    (let [calculated-length (bsp/bytes-read bis)
          magic-from-stream (bsp/read-unsigned-int32! bis)]

      (let [lb (.getLowBits l)
            hb (.getHighBits l)
            bits (bit-switch l)]
        (cond
          (<= 1 bits 14)
          (do
            (bsp/write! bos (.-INT c/codes))
            (bsp/write-int32! bos hb)
            (bsp/write-int32! bos lb))
          (<= 15 bits 22)
          (let [ic (bit-shift-right hb 16)]
            (do
              (bsp/write! bos (+ (.-INT_PACKED_7_ZERO c/codes) ic))
              (bsp/write-int16! bos hb)
              (bsp/write-int32! bos lb)))
          (<= 23 bits 30)
          (let [ic (bit-shift-right hb 8)]
            (do
              (bsp/write! bos (+ (.-INT_PACKED_6_ZERO c/codes) ic))
              (bsp/write! bos hb)
              (bsp/write-int32! bos lb)))
          (<= 31 bits 38)
          (do
            (bsp/write! bos (+ (.-INT_PACKED_5_ZERO c/codes) hb))
            (bsp/write-int32! bos lb))
          (<= 39 bits 44)
          (do
            (bsp/write! bos (+ (.-INT_PACKED_4_ZERO c/codes) (bit-shift-right lb 24)))
            (bsp/write-int24! bos lb))
          (<= 45 bits 51)
          (do
            (bsp/write! bos (+ (.-INT_PACKED_3_ZERO c/codes) (bit-shift-right lb 16)))
            (bsp/write-int16! bos lb))
          (<= 52 bits 57)
          (do
            (bsp/write! bos (+ (.-INT_PACKED_2_ZERO c/codes) (bit-shift-right lb 8)))
            (bsp/write! bos lb))
          (<= 58 bits 64)
          (do
            (when (< lb -1)
              (bsp/write! bos (+ (.-INT_PACKED_2_ZERO c/codes) (bit-shift-right lb 8))))
            (bsp/write! bos lb))
          :else
          (throw (js/Error. (str "Long (" l ") can not be converted")))))
      bos))
  (write-float! [bos f]
