anchor.diff:  priv_end_session(_SessionToken) ->
       ok.
   
  --spec priv_submit_payload(User, SessionToken, Payload, State) ->
  -                                 {{ok, payload_added}} |
  -                                 {ok, payload_added, session_ended} |
  -                                 {error, Reason}
  +-spec priv_submit_payload(User, SessionToken, Payload, State, Final) ->
  +                                 {{ok, payload_added} |
  +                                  {ok, payload_added, session_ended} |
  +                                  {error, invalid_token}, State}
                                        when User :: binary(),
                                             SessionToken :: binary(),
                                             Payload :: binary(),
                                             State :: map(),
  -                                          Reason :: binary().
  -priv_submit_payload(User, SessionToken, Payload, State) ->
  +                                          Final :: boolean().
  +priv_submit_payload(User, SessionToken, Payload, State, Final) ->
       case priv_check_payload(User, SessionToken, Payload, State) of
           ok ->
  -            %% Acquire lease on the subpath and submit payload to GW
  -
  -            %% If Final == true, request session end
  -            {ok, payload_added};
  -        {error, Reason} ->
  +            %% TODO Acquire lease on the subpath and submit payload to GW
  +
  +            case Final of
  +                true ->
  +                    {{ok, payload_added, session_ended},
  +                     priv_delete_token(State, SessionToken)};
  +                false ->
  +                    {{ok, payload_added}, State}
  +            end;
  +        {error, invalid_token} ->
               %% Payload is invalid, return with reason
  -            {error, Reason}
  +            {{error, invalid_token}, State}
       end.
   
   -spec priv_generate_token(User, Path) -> {Token, Public, Secret}
  
positive.code:     V3 = macaroon_verifier:satisfy_general(V2, CheckPaths),
  
      macaroon_verifier:verify(V3, M, Secret).
  
negative.code:                                          State :: map().
  priv_check_payload(_User, _SessionToken, _Payload, State)
    when map_size(State) == 0 ->
      {error, invalid_token};
  priv_check_payload(User, SessionToken, _Payload, State) ->
      % Here we should perform all sanity checks on the request
  
  