anchor.diff:  
   flush_buffer(#state{worker = Worker,
                       buffer = Buffer,
  -                    buffer_size = BufferSize} = State) ->
  +                    buffer_size = BufferSize,
  +                    outstanding_size = OutstandingSize} = State) ->
       Worker ! {write, Buffer, BufferSize},
       cancel_flush_timer(State#state{buffer = <<>>,
  -                                   buffer_size = 0}).
  +                                   buffer_size = 0,
  +                                   outstanding_size = OutstandingSize + BufferSize}).
   
   maybe_arm_flush_timer(#state{flush_timer = undefined,
                                batch_timeout = Timeout} = State) ->
  
positive.code: 
      State = #state{buffer = <<>>,
                     buffer_size = 0,
                     batch_size = BatchSize,
                     batch_timeout = BatchTimeout,
                     worker = Worker},
  
      {ok, State}.
  
negative.code: 
  handle_info(flush_buffer, State) ->
      {noreply, flush_buffer(State)};
  handle_info({written, Written}, #state{buffer_size = BufferSize,
                                         outstanding_size = OutstandingSize,
                                         buffer_overflow = Overflow,
                                         buffer_size_max = BufferSizeMax,
                                         dropped_messages = Dropped} = State) ->
      true = OutstandingSize >= Written,
      NewOutstandingSize = OutstandingSize - Written,
  
      NewTotalSize = BufferSize + NewOutstandingSize,
      NewState =
          case Overflow =:= true andalso 2 * NewTotalSize =< BufferSizeMax of
              true ->
                  Msg = <<"Dropped ",
                          (list_to_binary(integer_to_list(Dropped)))/binary,
                          " messages\n">>,
                  State1 = do_log_msg(Msg, State),
                  State1#state{buffer_overflow = false,
                               dropped_messages = 0,
                               outstanding_size = NewOutstandingSize};
              false ->
                  State#state{outstanding_size = NewOutstandingSize}
          end,
      {noreply, NewState};
  handle_info({'EXIT', Worker, Reason}, #state{worker = Worker} = State) ->
      {stop, {worker_died, Worker, Reason}, State#state{worker = undefined}};
  handle_info({'EXIT', Pid, Reason}, State) ->
  