anchor.diff:          false ->
               S
       end,
  -    {noreply, NewState, get_timeout(NewState)};
  +    {State, Sleep} = prepare_sleep(NewState),
  +    {noreply, State, Sleep};
  +
   handle_info(Msg, State) ->
       io:format("Unknown message received: ~p~n", [Msg]),
       {noreply, State}.
  
positive.code:                        S#state.waiting),
      Monitors = gb_sets:add(Ref, S#state.monitors),
      NewState = S#state{waiting=Waiting, monitors=Monitors},
      {noreply, NewState, get_timeout(NewState)};
  handle_call({done, UUID}, _From, S=#state{}) ->
      {reply, lmq_lib:done(S#state.name, UUID), S, get_timeout(S)};
  handle_call({retain, UUID}, _From, S=#state{props=Props}) ->
      R = lmq_lib:retain(S#state.name, UUID, proplists:get_value(timeout, Props)),
      {reply, R, S, get_timeout(S)};
  handle_call({release, UUID}, _From, S=#state{}) ->
      {reply, lmq_lib:release(S#state.name, UUID), S, get_timeout(S)};
  handle_call(stop, _From, State) ->
      {stop, normal, ok, State}.
  
  
negative.code: wait_valid(#waiting{start_time=StartTime, timeout=Timeout}) ->
      StartTime + Timeout > lmq_misc:unixtime().
  
  prepare_sleep(S=#state{}) ->
      case queue:is_empty(S#state.waiting) of
          true  -> {S, infinity};
          false ->
              case lmq_lib:waittime(S#state.name) of
                  0 -> {S, 0};
                  T ->
                      %% remove invalid waitings before sleeping
                      F = fun(W=#waiting{}) ->
                          case wait_valid(W) of
                              true -> true;
                              false ->
                                  gen_server:reply(W#waiting.from, {error, timeout}),
                                  false
                          end
                      end,
                      {S#state{waiting=queue:filter(F, S#state.waiting)}, T}
              end
      end.
  
  get_retry(Props) ->
  