anchor.diff:  
   %% == public ==
   
  --spec connect([term()]) -> {ok,undefined,protocol()}|{error,_,protocol()}.
  +-spec connect([term()]) -> {ok,protocol()}|{error,_}|{error,_,protocol()}.
   connect(Args)
  -  when is_list(Args), 6 == length(Args) -> % TODO: proplists?
  -    L = [fun connect_pre/7, fun recv_status/1, fun connect_post/2],
  -    loop(#protocol{}, Args, L).
  -
  --spec close(protocol()) -> {ok,undefined,protocol()}|{error,_,protocol()}.
  +  when is_list(Args), 6 =:= length(Args) ->
  +    loop(Args, [fun connect_pre/6, fun recv_status/1, fun connect_post/2]).
  +
  +-spec close(protocol()) -> {ok,protocol()}|{error,_}|{error,_,protocol()}.
   close(#protocol{handle=undefined}=P) ->
  -    {ok, undefined, P};
  +    {ok, P};
   close(#protocol{}=P) ->
  -    L = [fun close_pre/1, fun send/2, fun close_post/1],
  -    loop(P, [], L).
  -
  --spec auth(protocol(),binary(),binary(),binary())
  -          -> {ok,result(),protocol()}|{error,_,protocol()}.
  +    loop([P], [fun close_pre/1, fun send/2, fun close_post/1]).
  +
  +-spec auth(protocol(),binary(),binary(),binary()) -> {ok,result(),protocol()}|{error,_,protocol()}.
   auth(#protocol{handle=H}=P, User, Password, Database)
     when undefined =/= H, is_binary(User), is_binary(Password), is_binary(Database) ->
  -    L = [fun auth_pre/4, fun send/2, fun recv_status/1, fun auth_post/2],
  -    case loop(P, [User,Password,Database], L) of
  +    case loop([User,Password,Database,P],
  +              [fun auth_pre/4, fun send/2, fun recv_status/1, fun auth_post/2]) of
           {ok, #plugin{}=X, Protocol} ->
  -            auth_alt(merge(Protocol,X), Password);
  +            auth_alt([Password,merge(Protocol,X)]);
           {ok, Result, Protocol}->
               {ok, Result, Protocol};
           {error, Reason, Protocol} ->
               {error, Reason, Protocol}
       end.
   
  -auth_alt(Protocol, Password) ->
  -    L = [fun auth_alt_pre/2, fun send/2, fun recv_status/1, fun auth_alt_post/2],
  -    loop(Protocol, [Password], L).
  +auth_alt(Args) ->
  +    loop(Args, [fun auth_alt_pre/2, fun send/2, fun recv_status/1, fun auth_alt_post/2]).
   
   -spec ping(protocol()) -> {ok,result(),protocol()}|{error,_,protocol()}.
   ping(#protocol{handle=H}=P)
     when undefined =/= H ->
  -    L = [fun ping_pre/1, fun send/2, fun recv_status/1, fun recv_result/2],
  -    loop(P, [], L).
  +    loop([P], [fun ping_pre/1, fun send/2, fun recv_status/1, fun recv_result/2]).
   
   -spec stat(protocol()) -> {ok,binary(),protocol()}|{error,_,protocol()}.
   stat(#protocol{handle=H}=P)
     when undefined =/= H ->
  -    L = [fun stat_pre/1, fun send/2, fun recv_status/1, fun stat_post/2],
  -    loop(P, [], L).
  -
  --spec version(protocol()) -> {ok, [non_neg_integer()], protocol()}.
  -version(#protocol{version=V}=P) ->
  +    loop([P], [fun stat_pre/1, fun send/2, fun recv_status/1, fun stat_post/2]).
  +
  +-spec version(protocol()) -> {ok,[non_neg_integer()],protocol()}.
  +version(#protocol{handle=H,version=V}=P)
  +  when undefined =/= H ->
       {ok, V, P}.
   
   -spec real_query(protocol(),binary())
  
positive.code:                    {ok,{[field()],[term()],result()},protocol()}|{error,_,protocol()}.
  real_query(#protocol{handle=H}=P, Query)
    when undefined =/= H, is_binary(Query) ->
      L = [fun real_query_pre/2, fun send/2, fun recv_status/1, fun real_query_post/2],
      loop(P, [Query], L).
  
  -spec refresh(protocol(),integer()) -> {ok,result(),protocol()}|{error,_,protocol()}.
  refresh(#protocol{handle=H}=P, Options)
    when undefined =/= H ->
      L = [fun refresh_pre/2, fun send/2, fun recv_status/1, fun recv_result/2],
      loop(P, [Options], L).
  
  -spec select_db(protocol(),binary()) -> {ok,result(),protocol()}|{error,_,protocol()}.
  select_db(#protocol{handle=H}=P, Database)
    when undefined =/= H, is_binary(Database) ->
      L = [fun select_db_pre/2, fun send/2, fun recv_status/1, fun recv_result/2],
      loop(P, [Database], L).
  
  -spec stmt_prepare(protocol(),binary()) -> {ok,prepare(),protocol()}|{error,_,protocol()}.
  stmt_prepare(#protocol{handle=H}=P, Query)
    when undefined =/= H, is_binary(Query) ->
      L = [fun stmt_prepare_pre/2, fun send/2, fun recv_status/1, fun stmt_prepare_post/2],
      loop(P, [Query], L).
  
  -spec stmt_close(protocol(),prepare()) -> {ok,undefined,protocol()}|{error,_,protocol()}.
  stmt_close(#protocol{handle=H}=P, #prepare{}=X)
    when undefined =/= H ->
      L = [fun stmt_close_pre/2, fun send/3, fun stmt_close_post/2],
      loop(P, [X], L).
  
  -spec stmt_execute(protocol(),prepare(),[term()])
                    -> {ok,prepare(),protocol()}|
                       {ok,{[field()],[term()],prepare()},protocol()}|{error,_,protocol()}.
  stmt_execute(#protocol{handle=H}=P, #prepare{param_count=N}=X, Args)
    when undefined =/= H, is_list(Args), N == length(Args) ->
      L = [fun stmt_execute_pre/3, fun send/3, fun recv_status/2, fun stmt_execute_post/3],
      loop(P, [X,Args], L).
  
  -spec stmt_fetch(protocol(),prepare())
                  -> {ok,prepare(),protocol()}|
  
negative.code:   when undefined =/= H ->
      case R#result.status of
          S when ?ISSET(S,?SERVER_STATUS_CURSOR_EXISTS) ->
              loop([X,P], [fun stmt_fetch_pre/2, fun send/3, fun stmt_fetch_post/2]);
          _ ->
              {ok, X, P}
      end.
  