anchor.diff:  %%% Internal functions
   %%%===================================================================
   
  --spec p_generate_token(KeyId, Path, MaxLeaseTime, WorkerPort, Timeout)
  +-spec p_generate_token(KeyId, Path, MaxLeaseTime, WorkerPort, From, Timeout)
                         -> {Token, Public, Secret}
                                when KeyId :: binary(),
                                     Path :: binary(),
                                     MaxLeaseTime :: integer(),
                                     WorkerPort :: port(),
  +                                  From :: pid(),
                                     Timeout :: integer(),
                                     Token :: binary(),
                                     Public :: binary(),
                                     Secret :: binary().
  -p_generate_token(KeyId, Path, MaxLeaseTime, WorkerPort, Timeout) ->
  +p_generate_token(KeyId, Path, MaxLeaseTime, WorkerPort, From, Timeout) ->
       ReqBody = jsx:encode(#{<<"key_id">> => KeyId, <<"path">> => Path,
                             <<"max_lease_time">> => MaxLeaseTime}),
       p_write_request(WorkerPort, ?kGenerateToken, ReqBody),
  -    {ok, {_Size, ReplyBody}} = p_read_reply(WorkerPort, Timeout),
  -    #{<<"token">> := Token, <<"id">> := Public, <<"secret">> := Secret}
  -        = jsx:decode(ReplyBody, [return_maps]),
  -    {Public, Secret, Token}.
  -
  -
  --spec p_get_token_id(Token, WorkerPort, Timeout)
  +    case p_read_reply(WorkerPort, Timeout) of
  +        {ok, {_Size, ReplyBody}} ->
  +            #{<<"token">> := Token, <<"id">> := Public, <<"secret">> := Secret}
  +                    = jsx:decode(ReplyBody, [return_maps]),
  +            {Public, Secret, Token};
  +        {error, worker_died} ->
  +            gen_server:reply(From, {error, worker_died}),
  +            exit(self(), kill)
  +    end.
  +
  +
  +-spec p_get_token_id(Token, WorkerPort, From, Timeout)
                       -> {ok, PublicId} | {error, invalid_macaroon}
                              when Token :: binary(),
                                   WorkerPort :: port(),
  +                                From :: pid(),
                                   Timeout :: integer(),
                                   PublicId :: binary().
  -p_get_token_id(Token, WorkerPort, Timeout) ->
  +p_get_token_id(Token, WorkerPort, From, Timeout) ->
       p_write_request(WorkerPort, ?kGetTokenId, Token),
       case p_read_reply(WorkerPort, Timeout) of
           {ok, {_, Reply}} ->
  
positive.code:     receive
          {Port, {exit_status, Status}} ->
              lager:error("Worker process at port ~p died with status: ~p", [Port, Status]),
              exit(worker_died);
          {Port, {data, <<Size:32/integer-signed-little,Msg/binary>>}} ->
              {ok, {Size, Msg}}
      after
  
negative.code:                 #{<<"status">> := <<"error">>, <<"reason">> := <<"invalid_token">>} ->
                      {error, invalid_lease}
              end;
          {error, worker_died} ->
              gen_server:reply(From, {error, worker_died}),
              exit(self(), kill);
          {error, worker_timeout} ->
              lager:error("Timeout reached waiting for reply from worker ~p", [WorkerPort]),
              {error, worker_timeout}
      end.
  
  
  -spec p_commit(WorkerPort, LeasePath, OldRootHash, NewRootHash, RepoTag, From, Timeout)
                -> ok | {error, merge_error | io_error | worker_timeout}
                                          when WorkerPort :: port(),
                                               LeasePath :: binary(),
                                               OldRootHash :: binary(),
                                               NewRootHash :: binary(),
                                               RepoTag :: cvmfs_common_types:repository_tag(),
                                               From :: pid(),
                                               Timeout :: integer().
  p_commit(WorkerPort, LeasePath, OldRootHash, NewRootHash, RepoTag, From, Timeout) ->
      {TagName, TagChannel, TagDescription} = RepoTag,
      Req1 = jsx:encode(#{<<"lease_path">> => LeasePath,
                          <<"old_root_hash">> => OldRootHash,
  