anchor.diff:                                 dalmatiner_db, max_bkt_batch_size, 500),
                       stream_loop(Socket, Transport,
                                   #sstate{max_diff = Delay,
  -                                        dict_mod = DictMod,
                                           max_bkt_batch_size = BDSize,
  -                                        dict = DictMod:new(Bucket,
  -                                                            State#state.n,
  -                                                            State#state.w,
  -                                                            false)},
  +                                        dict = btk_pdict:new(Bucket,
  +                                                             State#state.n,
  +                                                             State#state.w,
  +                                                             false)},
                                   {incomplete, <<>>});
                   {stream_v2, Bucket, Delay, HPTS} ->
                       true = dalmatiner_opt:bucket_exists(Bucket),
  
positive.code:                          ok.
  stream_loop(Socket, Transport,
              State = #sstate{
                         dict_mod = DictMod,
                         dict = Dict},
              {flush, Rest}) ->
      Dict1 = flush(DictMod, Dict),
      stream_loop(Socket, Transport, State#sstate{dict = Dict1},
                  dproto_tcp:decode_stream(Rest));
  
  stream_loop(Socket, Transport,
              State = #sstate{dict = Dict, last = undefined,
                              dict_mod = DictMod,
                              max_bkt_batch_size = BDSize},
              {{stream, Metric, Time, Points}, Rest}) ->
      Dict1 = DictMod:add(Metric, Time, Points, Dict),
      Dict2 = case DictMod:size(Dict1) of
                  X when X > BDSize ->
                      flush(DictMod, Dict1);
                  _ ->
                      Dict1
              end,
  
negative.code: 
  stream_loop(Socket, Transport,
              State = #sstate{last = _L,
                              max_diff = _Max, dict = Dict},
              {{stream, Metric, Time, Points}, Rest})
    when Time - _L > _Max ->
      Dict1 = flush(Dict),
      Dict2 = bkt_pdict:add(Metric, Time, Points, Dict1),
      stream_loop(Socket, Transport, State#sstate{dict = Dict2, last = undefined},
                  dproto_tcp:decode_stream(Rest));
  
  stream_loop(Socket, Transport, State = #sstate{
                                            dict = Dict},
              {{stream, Metric, Time, Points}, Acc}) ->
      Dict1 = bkt_pdict:add(Metric, Time, Points, Dict),
      stream_loop(Socket, Transport, State#sstate{dict = Dict1},
                  dproto_tcp:decode_stream(Acc));
  
  stream_loop(Socket, Transport, State = #sstate{
                                            dict = Dict},
              {{batch, Time}, Acc}) ->
      %% When entering batch mode we make sure to drain the dict first and
      %% set last as undefined since we'll flush at the end too.
      %% TODO: figure out if this flushing makes sense or if we can make it
      %% conditional
      Dict1 = flush(Dict),
      batch_loop(Socket, Transport, State#sstate{dict = Dict1, last = undefined},
                 Time, decode_batch(Acc, State));
  
  stream_loop(Socket, Transport, State = #sstate{max_diff = D, recv_size = Size},
              {incomplete, Acc}) ->
      case Transport:recv(Socket, Size, min(D * 750, 5000)) of
          {ok, Data} ->
  