anchor.diff:  make_new_path([{bind, P}|Rest], Bindings, Remaining, Acc) ->
       P2 = case couch_util:get_value({bind, P}, Bindings) of
           undefined -> << "undefined">>;
  -        P1 -> P1
  +        P1 -> 
  +            iolist_to_binary(P1)
       end,
       make_new_path(Rest, Bindings, Remaining, [P2|Acc]);
   make_new_path([P|Rest], Bindings, Remaining, Acc) ->
  
positive.code: 
                      % build new path, reencode query args, eventually convert
                      % them to json
                      Path = lists:append(
                          string:join(Parts, [?SEPARATOR]),
                          case Bindings of
                              [] -> [];
                              _ -> [$?, encode_query(Bindings)]
                          end),
                      
                      % if path is relative detect it and rewrite path
                      case mochiweb_util:safe_relative_path(Path) of
  
negative.code: make_query_list([], _Bindings, Acc) ->
      Acc;
  make_query_list([{Key, {Value}}|Rest], Bindings, Acc) ->
      Value1 = {Value},
      make_query_list(Rest, Bindings, [{to_binding(Key), Value1}|Acc]);
  make_query_list([{Key, Value}|Rest], Bindings, Acc) when is_binary(Value) ->
      Value1 = replace_var(Value, Bindings),
      make_query_list(Rest, Bindings, [{to_binding(Key), Value1}|Acc]);
  make_query_list([{Key, Value}|Rest], Bindings, Acc) when is_list(Value) ->
      Value1 = replace_var(Value, Bindings),
      make_query_list(Rest, Bindings, [{to_binding(Key), Value1}|Acc]);
  make_query_list([{Key, Value}|Rest], Bindings, Acc) ->
      make_query_list(Rest, Bindings, [{to_binding(Key), Value}|Acc]).
  
  replace_var(<<"*">>=Value, Bindings) ->
      get_var(Value, Bindings, Value);
  replace_var(<<":", Var/binary>> = Value, Bindings) ->
      get_var(Var, Bindings, Value);
  replace_var(Value, _Bindings) when is_binary(Value) ->
      Value;
  replace_var(Value, Bindings) when is_list(Value) ->
      lists:reverse(lists:foldl(fun
                  (<<":", Var/binary>>=Value1, Acc) ->
                      [get_var(Var, Bindings, Value1)|Acc];
                  (Value1, Acc) ->
                      [Value1|Acc]
              end, [], Value));
  replace_var(Value, _Bindings) ->
      Value.
                      
  maybe_json(Key, Value) ->
      case lists:member(Key, [<<"key">>, <<"startkey">>, <<"start_key">>,
                  <<"endkey">>, <<"end_key">>, <<"keys">>]) of
          true ->
              ?JSON_ENCODE(Value);
          false ->
              Value
      end.
  
  get_var(VarName, Props, Default) ->
      VarName1 = to_binding(VarName),
      Val = couch_util:get_value(VarName1, Props, Default),
      Val.
  
  %% doc: build new patch from bindings. bindings are query args
  %% (+ dynamic query rewritten if needed) and bindings found in
  