anchor.diff:  %% @doc Check if the name is in a zone.
   -spec in_zone(binary()) -> boolean().
   in_zone(Name) ->
  -  case find_zone_in_cache(Name) of
  -    {ok, Zone} ->
  -      is_name_in_zone(Name, Zone);
  -    _ ->
  -      false
  -  end.
  +    case find_zone_in_cache(Name) of
  +        {ok, Zone} ->
  +            is_name_in_zone(Name, Zone);
  +        _ ->
  +            false
  +    end.
   
   %% @doc Return a list of tuples with each tuple as a name and the version SHA
   %% for the zone.
   -spec zone_names_and_versions() -> [{dns:dname(), binary()}].
   zone_names_and_versions() ->
  -  erldns_storage:foldl(fun(#zone{name = Name, version = Version}, NamesAndShas) ->
  -                         [{Name, Version} | NamesAndShas]
  -                       end, [], zones).
  -
  -% ----------------------------------------------------------------------------------------------------
  -% Write API
  +    erldns_storage:foldl(fun(#zone{name = Name, version = Version}, NamesAndShas) ->
  +                                 [{Name, Version} | NamesAndShas]
  +                         end, [], zones).
  +
  +%% -----------------------------------------------------------------------------------------------
  +%% Write API
   
   %% @doc Put a name and its records into the cache, along with a SHA which can be
   %% used to determine if the zone requires updating.
  
positive.code: %% @doc Start the zone cache process.
  -spec start_link() -> any().
  start_link() ->
    gen_server:start_link({local, ?SERVER}, ?MODULE, [], []).
  
  % ----------------------------------------------------------------------------------------------------
  % Read API
  
  %% @doc Find a zone for a given qname.
  -spec find_zone(dns:dname()) -> {ok, #zone{}} | {error, {zone_not_found, binary()}} | {error, not_authoritative}.
  find_zone(Qname) ->
    find_zone(normalize_name(Qname), get_authority(Qname)).
  
  %% @doc Find a zone for a given qname.
  -spec find_zone(dns:dname(), {error, any()} | {ok, dns:rr()} | [dns:rr()] | dns:rr()) ->
    {ok, #zone{}} | {error, {zone_not_found, binary()}} | {error, not_authoritative}.
  find_zone(Qname, {error, _}) ->
    find_zone(Qname, []);
  find_zone(Qname, {ok, Authority}) ->
    find_zone(Qname, Authority);
  find_zone(_Qname, []) ->
    {error, not_authoritative};
  find_zone(Qname, Authorities) when is_list(Authorities) ->
    find_zone(Qname, lists:last(Authorities));
  find_zone(Qname, Authority) when is_record(Authority, dns_rr) ->
    Name = normalize_name(Qname),
    case dns:dname_to_labels(Name) of
      [] -> {error, {zone_not_found, Name}};
      [_] -> {error, {zone_not_found, Name}};
      [_|Labels] ->
        case get_zone(Name) of
          {ok, Zone} -> Zone;
          {error, {zone_not_found, Name}} ->
            case Name =:= Authority#dns_rr.name of
              true -> {error, {zone_not_found, Name}};
              false -> find_zone(dns:labels_to_dname(Labels), Authority)
            end
        end
    end.
  
  %% @doc Get a zone for the specific name. This function will not attempt to resolve
  %% the dname in any way, it will simply look up the name in the underlying data store.
  -spec get_zone(dns:dname()) -> {ok, #zone{}} | {error, {zone_not_found, binary()}}.
  get_zone(Name) ->
    NormalizedName = normalize_name(Name),
    case erldns_storage:select(zones, NormalizedName) of
      [{NormalizedName, Zone}] ->
          {ok, Zone#zone{name = NormalizedName, records = [], records_by_name=trimmed}};
      _Res ->
          {error, {zone_not_found, NormalizedName}}
    end.
  
  %% @doc Get a zone for the specific name, including the records for the zone.
  -spec get_zone_with_records(dns:dname()) -> {ok, #zone{}} | {error, {zone_not_found, binary()}}.
  get_zone_with_records(Name) ->
    NormalizedName = normalize_name(Name),
    case erldns_storage:select(zones, NormalizedName) of
      [{NormalizedName, Zone}] -> {ok, Zone};
      _Error ->
          erldns_log:error("Error getting zone ~p: ~p", [NormalizedName, _Error]),
          {error, {zone_not_found, NormalizedName}}
    end.
  
  %% @doc Retrieve the allow_notify option from zone.
  -spec get_zone_allow_notify(binary()) -> [inet:ip_address()] | {error, {zone_not_found, binary()}}.
  get_zone_allow_notify(ZoneName) ->
      NormalizedName = normalize_name(ZoneName),
      case erldns_storage:select(zones, NormalizedName) of
        [{NormalizedName, Zone}] ->
            Zone#zone.allow_notify;
         _ ->
             {error, {zone_not_found, NormalizedName}}
      end.
  
  %% @doc Retrieve the allow_transfer option from zone.
  
negative.code: exclude_mname_duplicates(SOA, NameServers) ->
      MName = SOA#dns_rrdata_soa.mname,
      lists:foldl(fun(NameServer, Acc0) ->
                          case NameServer#dns_rrdata_ns.dname =:= MName of
                              true ->
                                  %% Found a NS record that is also a mname of an SOA, exclude it
                                  Acc0;
                              false ->
                                  [NameServer | Acc0]
                          end
                  end, [], NameServers).
  
  %% @doc This function takes a list of nameservers, finds it's A/AAAA record in the given record set
  %% and returns the nameserver's IP address.
  