anchor.diff:  -spec create_new_zone_expiration_orddict(integer(), orddict:orddict(),
                                            [{ZoneName :: binary(), BindIP :: inet:ip_address()}]) ->
                                                   orddict:orddict().
  -create_new_zone_expiration_orddict(_ExpirationKey, [], _ListOfExpiredZones) ->
  -    [];
  -create_new_zone_expiration_orddict(_ExpirationKey, Orddict, []) ->
  -    Orddict;
  -create_new_zone_expiration_orddict(ExpirationKey, Orddict, ListOfExpiredZones) ->
  -    Orddict0 = orddict:erase(ExpirationKey, Orddict),
  -    lists:flatten([orddict:append(get_expiration(ZoneName), Args, Orddict0)
  -                   || {ZoneName, _ServerIP} = Args <- ListOfExpiredZones]).
  +create_new_zone_expiration_orddict(ExpirationKey, Orddict0, ListOfExpiredZones) ->
  +    Orddict = orddict:erase(ExpirationKey, Orddict0),
  +    lists:flatten([begin
  +                       case get_expiration(ZoneName) of
  +                           {error, _Reason} ->
  +                               %%Zone must have been deleted. Dont append it.
  +                               Orddict;
  +                           Expiration ->
  +                               orddict:append(Expiration, Args, Orddict)
  +                       end
  +                   end || {ZoneName, _BindIP} = Args <- ListOfExpiredZones]).
   
   %% @doc Gets the expiration of the given zone name
   -spec get_expiration(binary()) -> integer().
   get_expiration(ZoneName) ->
  -    {ok, #zone{} = Zone} = erldns_zone_cache:get_zone_with_records(ZoneName),
  -    [#dns_rr{data = #dns_rrdata_soa{expire = Expire}}] = Zone#zone.authority,
  -    Expire + timestamp().
  +    case erldns_zone_cache:get_zone(ZoneName) of
  +        {ok, #zone{authority = [#dns_rr{data = #dns_rrdata_soa{expire = Expire}}]}} ->
  +            Expire + timestamp();
  +        {error, Reason} ->
  +            {error, Reason}
  +    end.
   
   %% @doc This function takes a zone  and the orrdict to add entries in the zone expiration
   %% orddict.
  
positive.code:             check_for_new_zones(OldZones, BindIP, add_zone_to_orddict(Zone, BindIP, Orddict), Tail)
      end.
  
  %% @doc This function creates a orrdict for the zones the slave  has. This orddict serves as
  %% a data structure that stores expiration as a key with the list of arguments necessary to
  %% initiate a zone transfer (AXFR) for the expired zone(s).
  %% @end
  -spec setup_zone_expiration_orddict() -> orddict:orddict().
  setup_zone_expiration_orddict() ->
      %% Get the bind IP we will use to send the AXFR
      ZoneNames = erldns_zone_cache:zone_names(),
      NewOrrdict = lists:foldl(
                     fun(ZoneName, Orrdict) ->
                             {ok, #zone{allow_transfer = AllowTransfer, notify_source = NotifySource,
                                        authority = [#dns_rr{data = ZoneAuth}]}}
                                 = erldns_zone_cache:get_zone_with_records(ZoneName),
                             case AllowTransfer of
                                 [] ->
                                     Orrdict;
                                 _ ->
                                     {MountedIP, _Port} = erldns_config:get_admin(),
                                     case NotifySource =:= MountedIP of
                                         true ->
                                             %% We are the zone Authority, we don't need to keep
                                             %% track of this zone.
                                             Orrdict;
                                         false ->
                                             %% We are slave of a zone, we need to keep track of it
                                             %% and send afxr when it expires
                                             Expiration = ZoneAuth#dns_rrdata_soa.expire + timestamp(),
                                             ArgsToSendAXFR = {ZoneName, MountedIP},
                                             orddict:append(Expiration, ArgsToSendAXFR, Orrdict)
                                     end
                             end
                     end,
                     orddict:new(),
  
negative.code: handle_info(timeout, #state{zone_expirations = Orddict0, orddict_size = Size, zones_in_cache = OldZones} = State) when Size > 0 ->
      Before = now(),
      Timestamp = timestamp(),
      NewZones = erldns_zone_cache:zone_names(),
      Orddict = check_for_new_zones(OldZones, erldns_config:get_primary_mounted_ip(), Orddict0, NewZones),
      NewOrddict = case hd(orddict:to_list(Orddict)) of
                       {Expiration, ListOfExpiredZones} when Expiration < Timestamp ->
                           create_new_zone_expiration_orddict(Expiration, Orddict, ListOfExpiredZones);
                       {Expiration, _ListOfExpiredZones} when Expiration >= Timestamp ->
                           Orddict
                   end,
      TimeSpentMs = timer:now_diff(now(), Before) div 1000,
      {noreply, State#state{zone_expirations = NewOrddict, orddict_size = orddict:size(NewOrddict),
                            zones_in_cache = NewZones},
       ?REFRESH_INTERVAL + TimeSpentMs};
  handle_info(timeout, #state{orddict_size = Size} = State) when Size =:= 0 ->
      Before = now(),
  