anchor.diff:              end,
               Message
       end;
  -
   %% When public, erldns should only respond to AXFR. Order here is necessary.
  -resolve(Message, AuthorityRecords, Qname, Qtype, {ClientIP, ServerIP}) ->
  -    case erldns_config:get_mode() of
  -        public ->
  -            Zone = erldns_zone_cache:find_zone(Qname, AuthorityRecords), % Zone lookup
  -            Records = resolve(Message, Qname, Qtype, Zone, {ClientIP, ServerIP}, _CnameChain = []),
  -            additional_processing(rewrite_soa_ttl(Records), ClientIP, Zone);
  -        hidden ->
  -            Message
  -    end.
  +resolve(Message, AuthorityRecords, Qname, Qtype, {ClientIP, ServerIP}, Mode) when Mode =:= public ->
  +    Zone = erldns_zone_cache:find_zone(Qname, AuthorityRecords), % Zone lookup
  +    Records = get_matched_records(Message, Qname, Qtype, Zone, {ClientIP, ServerIP}, _CnameChain = []),
  +    additional_processing(rewrite_soa_ttl(Records), ClientIP, Zone);
  +resolve(Message, _AuthorityRecords, _Qname, _Qtype, _IP, Mode) when Mode =:= hidden ->
  +    Message.
   
   %% No SOA was found for the Qname so we return the root hints
   %% Note: it seems odd that we are indicating we are authoritative here.
  -resolve(Message, _Qname, _Qtype, {error, not_authoritative}, {_ClientIP, _ServerIP}, _CnameChain) ->
  +get_matched_records(Message, _Qname, _Qtype, {error, not_authoritative}, {_ClientIP, _ServerIP}, _CnameChain) ->
       case erldns_config:use_root_hints() of
           true ->
               {Authority, Additional} = erldns_records:root_hints(),
  
positive.code:     resolve(Message, AuthorityRecords, {ClientIP, ServerIP}, Message#dns_message.questions).
  
  %% There were no questions in the message so just return it.
  -spec resolve(dns:message(), [dns:rr()], dns:ip(), dns:ip(), [dns:question()]) -> dns:message().
  resolve(Message, _AuthorityRecords, {_ClientIP, _ServerIP}, []) -> Message;
  %% There is one question in the message; resolve it.
  resolve(Message, AuthorityRecords, {ClientIP, ServerIP}, [Question]) ->
  
negative.code: 
  %% The CNAME is in the zone so we do not need to look it up again.
  restart_query(Message, Name, Qtype, {ClientIP, ServerIP}, CnameChain, Zone, true) ->
      get_matched_records(Message, Name, Qtype, Zone, {ClientIP, ServerIP}, CnameChain);
  %% The CNAME is not in the zone, so we need to find the zone using the
  %% CNAME content.
  restart_query(Message, Name, Qtype, {ClientIP, ServerIP}, CnameChain, _Zone, false) ->
      get_matched_records(Message, Name, Qtype, erldns_zone_cache:find_zone(Name), {ClientIP, ServerIP}, CnameChain).
  
  %% Delegated, but in the same zone.
  restart_delegated_query(Message, Name, Qtype, {ClientIP, ServerIP}, CnameChain, Zone, true) ->
      get_matched_records(Message, Name, Qtype, Zone, {ClientIP, ServerIP}, CnameChain);
  %% Delegated to a different zone.
  restart_delegated_query(Message, Name, Qtype, {ClientIP, ServerIP}, CnameChain, Zone, false) ->
      get_matched_records(Message, Name, Qtype, erldns_zone_cache:find_zone(Name, Zone#zone.authority),
              {ClientIP, ServerIP}, CnameChain). % Zone lookup
  
  
  