 (def ^:const path-mask (dec (bit-shift-left 1 level-shift)))
 (def ^:const empty-path 0)
 
-(defn path-get ^long [path level]
+(defn path-get ^long [^long path ^long level]
   (bit-and path-mask
            (unsigned-bit-shift-right path level)))
 
-(defn path-set ^long [path level idx]
+(defn path-set ^long [^long path ^long level ^long idx]
   (bit-or path 
           (bit-shift-left idx level)))
 
-(defn binary-search-l [cmp arr l r k]
-  ;; TODO less loop args?
-  (if (<= l r)
-    (let [m  (shim/half (+ l r))
-          mk (shim/aget arr m)]
-      (if (neg? (cmp mk k))
-        (recur cmp arr (inc m) r k)
-        (recur cmp arr l (dec m) k)))
-    l))
-
-
-(defn binary-search-r [cmp arr l r k]
-  ;; TODO less loop args?
-  (if (<= l r)
-    (let [m  (shim/half (+ l r))
-          mk (shim/aget arr m)]
-      (if (pos? (cmp mk k))
-        (recur cmp arr l (dec m) k)
-        (recur cmp arr (inc m) r k)))
-    l))
-
-(defn lookup-exact [cmp arr key]
+(defn binary-search-l ^long [cmp arr ^long r k]
+  (loop [l 0
+         r (long r)]
+    (if (<= l r)
+      (let [m  (shim/half (+ l r))
+            mk (shim/aget arr m)]
+        (if (neg? (cmp mk k))
+          (recur (inc m) r)
+          (recur l (dec m))))
+      l)))
+
+
+(defn binary-search-r ^long [cmp arr ^long r k]
+  (loop [l 0
+         r (long r)]
+    (if (<= l r)
+      (let [m  (shim/half (+ l r))
+            mk (shim/aget arr m)]
+        (if (pos? (cmp mk k))
+          (recur l (dec m))
+          (recur (inc m) r)))
+      l)))
+
+(defn lookup-exact ^long [cmp arr key]
   (let [arr-l (shim/alength arr)
-        idx   (binary-search-l cmp arr 0 (dec arr-l) key)]
+        idx   (binary-search-l cmp arr (dec arr-l) key)]
     (if (and (< idx arr-l)
              (== 0 (cmp (shim/aget arr idx) key)))
       idx
       -1)))
 
-(defn lookup-range [cmp arr key]
+(defn lookup-range ^long [cmp arr key]
   (let [arr-l (shim/alength arr)
-        idx   (binary-search-l cmp arr 0 (dec arr-l) key)]
+        idx   (binary-search-l cmp arr (dec arr-l) key)]
     (if (== idx arr-l)
       -1
       idx)))

        (node-lookup (shim/aget pointers idx) cmp key))))
  
  (node-conj [_ cmp key]
    (let [idx   (binary-search-l cmp keys 0 (- (shim/alength keys) 2) key)
          nodes (node-conj (shim/aget pointers idx) cmp key)]
      (when nodes
        (let [new-keys     (check-n-splice cmp keys     idx (inc idx) (shim/amap node-lim-key nodes))

        (shim/aget keys idx))))

  (node-conj [_ cmp key]
    (let [idx    (binary-search-l cmp keys (dec (shim/alength keys)) key)
          keys-l (shim/alength keys)]
      (cond
        ;; element already here
