anchor.diff:      true ->
           %io:format("We need to split (leaf node)~n~p~n", [LeafNode]),
           Children = load_nodes(Fd, ChildrenPos),
  +        % NOTE vmx: for vtree:split/1 the nodes need to have a special format
  +        %     a tuple with their MBR, Meta and *their* position in the file
  +        %     (as opposed to the position of their children)
  +        Children2 = [{Mbr, Meta, Pos} || {{Mbr, Meta, _}, Pos} <-
  +                lists:zip(Children, ChildrenPos)],
  +?debugVal(ChildrenPos),
  +?debugVal(Children),
  +?debugVal(Children2),
           {SplittedMbr, {Node1Mbr, _, _}=Node1, {Node2Mbr, _, _}=Node2}
  -                = vtree:split_node(MergedMbr, #node{type=inner}, Children),
  +                = vtree:split_node({MergedMbr, #node{type=inner}, Children2}),
  +%                = vtree:split_node({MergedMbr, #node{type=inner}, ChildrenPos}),
  +?debugVal(Node1),
  +?debugVal(Node2),
           {ok, Pos1} = couch_file:append_term(Fd, Node1),
           {ok, Pos2} = couch_file:append_term(Fd, Node2),
  +?debugVal(Pos1),
  +?debugVal(Pos2),
           {splitted, SplittedMbr, {Node1Mbr, Pos1}, {Node2Mbr, Pos2}}
       end;
   insert_subtree(Fd, RootPos, Subtree, Level, Depth) ->
  -    {SubtreeMbr, SubtreePos} = Subtree,
  +?debugMsg("still works"),
  +    %{SubtreeMbr, SubtreePos} = Subtree,
  +    {SubtreeMbrs, _SubtreePosList} = lists:unzip(Subtree),
  +    % Calculate the MBR that enclosed both nodes, as both nodes should end up
  +    % in the same target node
  +    SubtreeMbr = vtree:calc_mbr(SubtreeMbrs),
  +?debugMsg("still works"),
       ?debugVal(RootPos),
       {ok, Parent} = couch_file:pread_term(Fd, RootPos),
       {ParentMbr, _ParentMeta, EntriesPos} = Parent,
  +?debugMsg("still works"),
       {{_LeastMbr, LeastPos}, LeastRest} = least_expansion(
               Fd, SubtreeMbr, EntriesPos),
  +    LeastRestPos = [Pos || {Mbr, Pos} <- LeastRest],
  +?debugMsg("still works"),
       case insert_subtree(Fd, LeastPos, Subtree, Level, Depth+1) of
       {ok, NewMbr, NewPos} ->
           MergedMbr = vtree:merge_mbr(ParentMbr, NewMbr),
  -        LeastRestPos = [Pos || {Mbr, Pos} <- LeastRest],
           NewNode = {MergedMbr, #node{type=inner}, [NewPos|LeastRestPos]},
           {ok, Pos} = couch_file:append_term(Fd, NewNode),
           {ok, NewMbr, Pos};
       {splitted, ChildMbr, {Child1Mbr, ChildPos1}, {Child2Mbr, ChildPos2}} ->
  +?debugMsg("still works"),
           MergedMbr = vtree:merge_mbr(ParentMbr, ChildMbr),
           LeastRestPos = [Pos || {Mbr, Pos} <- LeastRest],
           if
           % Both nodes of the split fit in the current inner node
           length(EntriesPos)+2 =< ?MAX_FILLED ->
  -            ChildrenPos = LeastRestPos ++ ChildPos1 ++ ChildPos2,
  +?debugMsg("still works"),
  +?debugVal(LeastRestPos),
  +?debugVal(ChildPos1),
  +?debugVal(ChildPos2),
  +            ChildrenPos = [ChildPos1, ChildPos2] ++ LeastRestPos,
               NewNode = {MergedMbr, #node{type=inner}, ChildrenPos},
  +?debugVal(NewNode),
               {ok, Pos} = couch_file:append_term(Fd, NewNode),
               {ok, MergedMbr, Pos};
           % We need to split the inner node
           true ->
  +?debugMsg("still works"),
               Child1 = {Child1Mbr, #node{type=inner}, ChildPos1},
               Child2 = {Child2Mbr, #node{type=inner}, ChildPos2},
  -            Children = load_nodes(Fd, LeastRest) ++ Child1 ++ Child2,
  +
  +            % NOTE vmx: for vtree:split/1 the nodes need to have a special
  +            %     format a tuple with their MBR, Meta and *their* position in
  +            %     the file (as opposed to the position of their children)
  +            Children = [{Mbr, Meta, Pos} || {{Mbr, Meta, _}, Pos} <-
  +                    lists:zip(load_nodes(Fd, LeastRestPos), LeastRestPos)],
  +            Children2 = [Child1, Child2] ++ Children,
  +?debugVal(Children2),
  +
               {SplittedMbr, {Node1Mbr, _, _}=Node1, {Node2Mbr, _, _}=Node2}
  -                    = vtree:split_node(MergedMbr, #node{type=inner}, Children),
  +                    = vtree:split_node({MergedMbr, #node{type=inner}, Children2}),
               {ok, Pos1} = couch_file:append_term(Fd, Node1),
               {ok, Pos2} = couch_file:append_term(Fd, Node2),
               {splitted, SplittedMbr, {Node1Mbr, Pos1}, {Node2Mbr, Pos2}}
  
positive.code:             %?debugVal(NewRootNodes),
              %NewRootNodesPos = write_nodes(Fd, NewRootNodes),
              %?debugVal(NewRootNodesPos),
              NewRootNode = {MergedMbr, #node{type=leaf}, [TargetPos|PosList]},
              {ok, NewOmtPos} = couch_file:append_term(Fd, NewRootNode),
              {NewOmtPos, TargetHeight+1};
          % split the node and create new root node
  
negative.code:          Fd, {ParentMbr, #node{type=inner}, PosList}),
      {ParentMbr, ParentPos}.
  
  % XXX vmx: insert_subtree and potentially other functions should be moved
  %     from the vtree_bulk to the vtree module
  % @doc inserts a subtree into an vtree at a specific level. Returns the
  % MBR and position in the file of the new root node.
  -spec insert_subtree(Fd::file:io_device(), RootPos::integer(),
          Subtree::[{mbr(), integer()}], Level::integer()) ->
          {ok, mbr(), integer()}.
  insert_subtree(Fd, RootPos, Subtree, Level) ->
      %insert_subtree(Fd, RootPos, Subtree, Level, 0),
      case insert_subtree(Fd, RootPos, Subtree, Level, 0) of
      {splitted, NodeMbr, {Node1Mbr, NodePos1}, {Node2Mbr, NodePos2}} ->
          Parent = {NodeMbr, #node{type=inner}, [NodePos1, NodePos2]},
          {ok, Pos} = couch_file:append_term(Fd, Parent),
          {ok, NodeMbr, Pos};
      {ok, NewMbr, NewPos} ->
          {ok, NewMbr, NewPos}
      end.
  
  -spec insert_subtree(Fd::file:io_device(), RootPos::integer(),
          Subtree::[{mbr(), integer()}], Level::integer(), Depth::integer()) ->
          {ok, mbr(), integer()} |
          {splitted, mbr(), {mbr(), integer()}, {mbr(), integer()}}.
  insert_subtree(Fd, RootPos, Subtree, Level, Depth) when Depth==Level ->
  ?debugMsg("still works"),
  ?debugVal(RootPos),
  ?debugVal(Subtree),
      %{SubtreeMbr, SubtreePos} = Subtree,
      {SubtreeMbrs, SubtreePosList} = lists:unzip(Subtree),
      {ok, Parent} = couch_file:pread_term(Fd, RootPos),
      {ParentMbr, ParentMeta, EntriesPos} = Parent,
      %MergedMbr = vtree:merge_mbr(SubtreeMbr, ParentMbr),
      MergedMbr = vtree:calc_mbr([ParentMbr|SubtreeMbrs]),
  ?debugVal(MergedMbr),
  
      %ChildrenPos = [SubtreePos|EntriesPos],
      ChildrenPos = SubtreePosList ++ EntriesPos,
      %ChildrenPos = [RootPos|SubtreePosList],
  ?debugVal(ChildrenPos),
      if
      length(ChildrenPos) =< ?MAX_FILLED ->
          NewNode = {MergedMbr, ParentMeta, ChildrenPos},
  