       if i == 0
         if w == 1 then [y] else [y, t1, t2]
       else
-        wh = Math.floor w/2
-        if i-1 < wh
-          [x, updateTree(wh, t1, i-1), t2]
+        if i-1 < half(w)
+          [x, updateTree(half(w), t1, i-1), t2]
         else
-          [x, t1, updateTree(wh, t2, i-1-wh)]
+          [x, t1, updateTree(half(w), t2, i-1-half(w))]
 
     step = (r, s, i) =>
       if s


  rest: ->
    if @trees
      [w,[x,t1,t2]] = @trees.first()
      new RandomAccessList(
        if w == 1
          @trees.rest()
        else
          wh = Math.floor w/2
          new List([wh, t1], new List([wh, t2], @trees.rest()))
      )

  lookup: (i) ->

      if i == 0
        x
      else if w > 1
        if i-1 < half(w)
          recur -> lookupTree(half(w), t1, i-1)
        else
          recur -> lookupTree(half(w), t2, i-1-half(w))

    step = (trees, i) ->
      if trees
