anchor.diff:  
   %%--------------------------------------------------------------------
   %% Function: fetch(Key, List)
  -%%           Key = string(), the name of a field in a sip message
  -%%                 header - all RFC 3261 formats are accepted
  +%%           Key  = string() | atom(), either the header name (string)
  +%%                  or the internal form of it (atom).
   %%           List = keylist record()
   %% Descrip.: return the contents of the header that matches Key
   %% Returns : list() of string(), the value of Key - Key may have
   %%           several values associated with it (e.g. the "Via"
   %%           header in sip requests)
   %%--------------------------------------------------------------------
  -fetch(Key, List) when record(List, keylist) ->
  -    fetchcase(to_lower(Key), List#keylist.list);
  -%% XXX redundant check
  -fetch(Key, List) ->
  -    erlang:fault("Keylist not wellformed", [Key, List]).
  +fetch(Key, List) when is_list(Key), is_record(List, keylist) ->
  +    fetchcase(normalize(Key), List#keylist.list);
  +fetch(Key, List) when is_atom(Key), is_record(List, keylist) ->
  +    fetchcase(Key, List#keylist.list).
   
   fetchcase(_Key, []) ->
       [];
  -fetchcase(Key, [Elem | _List]) when record(Elem, keyelem), Elem#keyelem.casekey == Key ->
  +fetchcase(Key, [#keyelem{key=Key}=Elem | _List]) ->
  +    %% match
       Elem#keyelem.item;
  -fetchcase(Key, [Elem | List]) when record(Elem, keyelem) ->
  -    fetchcase(Key, List);
  -fetchcase(Key, [Elem | List]) ->
  -%% XXX ok to crash process ? redundant check it will result in a crash any way
  -    erlang:fault("Keylist element not wellformed", [Key, [Elem | List]]).
  +fetchcase(Key, [Elem | List]) when is_record(Elem, keyelem) ->
  +    %% no match
  +    fetchcase(Key, List).
   
   %%--------------------------------------------------------------------
   %% Function: appendlist(Keylist, List)
  -%%           Keylist = list() of {Key, Item}
  -%%           List = keylist record()
  -%% Descrip.: do one append/2 for each entry in Keylist
  -%% Returns : keylist record()
  -%%--------------------------------------------------------------------
  -appendlist(Keylist, List) when record(Keylist, keylist) ->
  -    Func = fun ({Key, Item}, KeylistAcc) ->
  -		   append({Key, Item}, KeylistAcc)
  +%%           KeyList = keylist record()
  +%%           List    = list() of {Name, Item} or {Key, Name, Item}
  +%% Descrip.: do one append/2 for each entry in List
  +%% Returns : keylist record()
  +%%--------------------------------------------------------------------
  +%% {Name, Key, Item} tuples
  +appendlist(Keylist, [H | _] = List) when is_record(Keylist, keylist), size(H) == 3 ->
  +    Func = fun ({Key, Name, Item}, KeylistAcc) ->
  +		   append({Key, Name, Item}, KeylistAcc)
   	   end,
  -    lists:foldl(Func, Keylist, List).
  +    lists:foldl(Func, Keylist, List);
  +%% {Name, Item} tuples
  +appendlist(Keylist, [H | _] = List) when is_record(Keylist, keylist), size(H) == 2 ->
  +    Func = fun ({Name, Item}, KeylistAcc) ->
  +		   append({Name, Item}, KeylistAcc)
  +	   end,
  +    lists:foldl(Func, Keylist, List);
  +appendlist(Keylist, []) when is_record(Keylist, keylist) ->
  +    Keylist.
   
   %%--------------------------------------------------------------------
   %% Function: from_list(List)
  -%%           List = list() of {Key, Item}
  +%%           List = list() of {Name, Key, Item}
   %% Descrip.: create an empty keylist and add the List elements with
   %%           append/2
   %% Returns : keylist record()
   %%--------------------------------------------------------------------
  -from_list(List) ->
  +from_list(List) when is_list(List) ->
       appendlist(empty(), List).
   
   %% Function: empty()
  
positive.code: %% Returns : keylist record()
  %% Note    : use of atom() as keys (for well known keys) should
  %%           improve patternmatch speed. When matching a
  %%           E#keyelem.casekey against Casekey in the alternative
  %%           solution below, it may also be worth using one of the OTP
  %%           set modules so that the member check becomes O(log N)
  %%           instead of O(N).
  
negative.code: 	 set/3,
  	 copy/2,
  	 appendlist/2,
  	 map/2,
  	 normalize/1,
  	 test/0
  	]).
  
  %%--------------------------------------------------------------------
  