anchor.diff:    %lager:debug("Matched records are wildcard."),
     CnameRecords = lists:filter(erldns_records:match_type(?DNS_TYPE_CNAME), lists:map(erldns_records:replace_name(Qname), BestMatchRecords)),
     resolve_best_match_with_wildcard(Message, Qname, Qtype, Host, CnameChain, BestMatchRecords, Zone, CnameRecords);
  +%% It is not a wildcard.
   resolve_best_match(Message, Qname, _Qtype, _Host, _CnameChain, _BestMatchRecords, Zone, false) ->
     %lager:debug("Matched records are not wildcard."),
     [Question|_] = Message#dns_message.questions,
  -  resolve_best_match_not_wildcard(Message, Zone, Qname =:= Question#dns_query.name).
  -
  -
  -
  -resolve_best_match_not_wildcard(Message, _Zone, false) ->
  -  %lager:debug("Qname did not match query name"),
  -  {Authority, Additional} = erldns_records:root_hints(),
  -  Message#dns_message{authority=Authority, additional=Additional};
  -resolve_best_match_not_wildcard(Message, Zone, true) ->
  -  %lager:debug("Qname matched query name"),
  -  Message#dns_message{rc = ?DNS_RCODE_NXDOMAIN, authority = Zone#zone.authority, aa = true}.
  -
  -% It's not a wildcard CNAME
  +  case Qname =:= Question#dns_query.name of
  +    true ->
  +      Message#dns_message{rc = ?DNS_RCODE_NXDOMAIN, authority = Zone#zone.authority, aa = true};
  +    false ->
  +      % TODO: this case does not appear to have any tests in the dnstest suite.
  +      % Why is it here?
  +      {Authority, Additional} = erldns_records:root_hints(),
  +      Message#dns_message{authority=Authority, additional=Additional}
  +  end.
  +
  +
  +% It's a wildcard CNAME
   resolve_best_match_with_wildcard(Message, Qname, Qtype, Host, CnameChain, MatchedRecords, Zone, []) ->
     %lager:debug("Resolving best match with wildcard"),
     TypeMatchedRecords = case Qtype of
  
positive.code:   resolve_best_match_referral(Message, Qname, Qtype, Host, CnameChain, BestMatchRecords, Zone, ReferralRecords).
  
  
  
  resolve_best_match(Message, Qname, Qtype, Host, CnameChain, BestMatchRecords, Zone) ->
    %lager:debug("No referrals found"),
    resolve_best_match(Message, Qname, Qtype, Host, CnameChain, BestMatchRecords, Zone, lists:any(erldns_records:match_wildcard(), BestMatchRecords)).
  
negative.code:   % It isn't clear what the QTYPE should be on a delegated restart. I assume an A record.
    restart_delegated_query(Message, Name, ?DNS_TYPE_A, Host, CnameChain, Zone, erldns_zone_cache:in_zone(Name));
  
  %% There was an exact type match for an NS query and an SOA record.
  resolve_exact_type_match(Message, _Qname, ?DNS_TYPE_NS, _Host, _CnameChain, MatchedRecords, _Zone, _AuthorityRecords) ->
    %lager:debug("Authoritative for record, returning answers"),
    Message#dns_message{aa = true, rc = ?DNS_RCODE_NOERROR, answers = Message#dns_message.answers ++ MatchedRecords};
  
  %% There was an exact type match for something other than an NS record and we are authoritative because there is an SOA record.
  resolve_exact_type_match(Message, Qname, Qtype, Host, CnameChain, MatchedRecords, Zone, _AuthorityRecords) ->
    % NOTE: this is a potential bug because it assumes the last record is the one to examine.
    Answer = lists:last(MatchedRecords),
    SoaRecordResult = erldns_zone_cache:get_authority(Qname),
    case NSRecords = erldns_zone_cache:get_delegations(Answer#dns_rr.name) of
  