anchor.diff:  %% include in the SOA's mname field.
   %% @end
   -spec exclude_mname_duplicates(dns:rr(), [dns:rr()]) -> [dns:rr()].
  -exclude_mname_duplicates(SOA, NameServers) ->
  -    MName = SOA#dns_rrdata_soa.mname,
  -    lists:foldl(fun(NameServer, Acc0) ->
  -                        case NameServer#dns_rrdata_ns.dname =:= MName of
  +exclude_mname_duplicates(#dns_rrdata_soa{mname = MName}, NameServers) ->
  +    lists:foldl(fun(#dns_rrdata_ns{dname = DName} = NameServer, Acc0) ->
  +                        case DName =:= MName of
                               true ->
                                   %% Found a NS record that is also a mname of an SOA, exclude it
                                   Acc0;
  
positive.code:             end
      end.
  
  build_zone(Qname, AllowNotifyList, AllowTransferList, AllowUpdateList, AlsoNotifyList,
             NotifySourceIP, Version, Records) ->
      RecordsByName = build_named_index(Records),
      Authority = lists:filter(erldns_records:match_type(?DNS_TYPE_SOA), Records),
      #zone{name = Qname, allow_notify = AllowNotifyList, allow_transfer = AllowTransferList,
            allow_update = AllowUpdateList, also_notify = AlsoNotifyList, notify_source = NotifySourceIP,
            version = Version, record_count = length(Records), authority = Authority, records = Records,
            records_by_name = RecordsByName}.
  
  build_zone(Qname, AllowNotifyList, AllowTransferList, AllowUpdateList, AlsoNotifyList,
             NotifySourceIP, Version, Authority, Records) ->
      RecordsByName = build_named_index(Records),
      #zone{name = Qname, allow_notify = AllowNotifyList, allow_transfer = AllowTransferList,
            allow_update = AllowUpdateList, also_notify = AlsoNotifyList, notify_source = NotifySourceIP,
            version = Version, record_count = length(Records), authority = Authority, records = Records,
            records_by_name = RecordsByName}.
  
  build_named_index(Records) -> build_named_index(Records, dict:new()).
  build_named_index([], Idx) -> Idx;
  build_named_index([R|Rest], Idx) ->
      Expiry = timestamp() + R#dns_rr.ttl,
      case dict:find(R#dns_rr.name, Idx) of
          {ok, Records} ->
              build_named_index(Rest, dict:store(normalize_name(R#dns_rr.name), Records ++ [{Expiry, R}], Idx));
          error ->
              build_named_index(Rest, dict:store(normalize_name(R#dns_rr.name), [{Expiry, R}], Idx))
      end.
  
  normalize_name(Name) when is_list(Name) -> string:to_lower(Name);
  
negative.code:     lists:foldl(fun(IP, Acc) ->
                          [gen_server:cast(erldns_manager, {send_notify, {BindIP, IP,
                                                                          ZoneName, ?DNS_CLASS_IN}}) | Acc]
                  end, [], get_ips_for_notify_set(Records)).
  
  %% @doc This function returns a list of nameservers to notify for a zone. Returned list
  %% excludes the mname that is specified in the authority.
  