anchor.diff:  handle_info(timeout, State) ->
       ok = update_uid(self()),
       {noreply, State};
  -handle_info({idle, {'*', [_, <<"EXISTS">>]}}, State) ->
  -    {noreply, update_uid_internal(State)};
  -handle_info({idle, {'*', [_, <<"EXPUNGE">>]}}, State) ->
  +handle_info({idle, {'*', [_, Notification]}}, State)
  +  when Notification =:= <<"EXISTS">> orelse Notification =:= <<"EXPUNGE">> ->
       {noreply, update_uid_internal(State)};
   handle_info({idle, {'+', [<<"idling">>]}}, State) ->
  -    {noreply, State};
  +    % Set the initial UID values.
  +    {noreply, update_uid_internal(State)};
   handle_info({idle, Msg}, State) ->
  -    lager:info("Unrecognized msg: ~p", [Msg]),
  -    {noreply, State};
  -
  -%% Catchall
  -handle_info(_Info, State) ->
  +    lager:warning("Unrecognized msg: ~p", [Msg]),
       {noreply, State}.
   
   
  
positive.code:        fun current_uid_asserts/1]}].
  
  update_uid_internal_asserts(Accounts) ->
      [?_assertMatch({state, _, _, LastUid, _} when is_integer(LastUid),
                     switchboard_operator:update_uid_internal(
                      {state, A, M, none, none})) %% This is sketchy....
       || {A, M} <- Accounts].
  
  current_uid_asserts(Accounts) ->
      [?_assertMatch({ok, _},
                     switchboard_operator:current_uid(A, M)) || {A, M} <- Accounts].
  
  -endif.
  
negative.code: %%==============================================================================
  
  %% @private
  
  %% @doc Updates the State's uid, publishing messages as necessary. `last_uid' is
  %% used as a reference point: when this function is called with a state where
  %% `#state{last_uid=none}' it will set the last_uid, and consider no messages to
  %% be new.
  %%
  %% @todo uid validity checks
  -spec update_uid_internal(#state{}) ->
      #state{}.
  update_uid_internal(#state{account=Account,
                             mailbox=Mailbox} = State) ->
      {ok, Uid} = current_uid(Account, Mailbox),
      update_uid_internal(State, Uid).
  
  update_uid_internal(#state{last_uid=none} = State, Uid) ->
      State#state{last_uid=Uid};
  update_uid_internal(#state{last_uid=LastUid} = State, Uid)
    when Uid =< LastUid ->
      State;
  update_uid_internal(#state{account=Account,
                             mailbox=Mailbox,
                             last_uid=LastUid} = State,
                      Uid) when Uid > LastUid ->
      {ok, {_, Emails}} = imap:call(switchboard:where(Account, active),
                                    {uid, {fetch, {LastUid + 1, Uid}, <<"ALL">>}}),
      lists:foreach(
        fun({fetch, Data}) ->
                switchboard:publish(new, {new, {Account, Mailbox}, Data})
        end, lists:map(fun imap:clean/1, Emails)),
      State#state{last_uid=Uid}.
  
  %% @private
  %% @doc Helper function to get the fetch command's result's UID.
  