anchor.diff:      mutators = Mutators,
       deleted = Deleted,
       value = Record
  -}) ->
  +}, _State) ->
       Fields = lists:foldl(fun({FieldName, FieldIndex}, Acc) ->
           Acc#{FieldName => element(FieldIndex, Record)}
       end, #{}, FieldsNamesAndIndexes),
  
positive.code: -spec stream_loop(req(), maps:map()) -> ok.
  stream_loop(Req, State = #{
      timeout := Timeout,
      ref := Ref,
      space_id := SpaceId,
      changes_reqs := ChangesReqs
  }) ->
      receive
          {Ref, stream_ended} ->
              ok;
          {Ref, #document{} = ChangedDoc} ->
              try
                  send_change(Req, SpaceId, ChangesReqs, ChangedDoc)
              catch
                  _:E ->
                      % Can appear when document connected with deleted file_meta appears
  
negative.code: %% and other documents for which user set `always` flag.
  %% @end
  %%--------------------------------------------------------------------
  -spec get_all_docs_changes(file_meta:uuid(), datastore:doc(), map()) ->
      maps:map().
  get_all_docs_changes(FileUuid, ChangedDoc, State) ->
      lists:foldl(fun(ChangesReq, Acc) ->
          maps:merge(Acc, get_requested_changes(ChangesReq, FileUuid, ChangedDoc, State))
      end, #{}, maps:get(changes_reqs, State)).
  
  
  %% @private
  -spec get_requested_changes(change_req(), file_meta:uuid(), datastore:doc(), map()) ->
      maps:map().
  get_requested_changes(#change_req{record = times} = Req, FileUuid, ChangedDoc, State) ->
      get_times_changes(Req, FileUuid, ChangedDoc, State);
  get_requested_changes(#change_req{record = file_meta} = Req, FileUuid, ChangedDoc, State) ->
      get_file_meta_changes(Req, FileUuid, ChangedDoc, State);
  get_requested_changes(#change_req{record = file_location} = Req, FileUuid, ChangedDoc, State) ->
      get_file_location_changes(Req, FileUuid, ChangedDoc, State);
  get_requested_changes(#change_req{record = custom_metadata} = Req, FileUuid, ChangedDoc, State) ->
      get_custom_meta_changes(Req, FileUuid, ChangedDoc, State).
  
  
  %% @private
  -spec get_times_changes(change_req(), file_meta:uuid(), datastore:doc(), map()) ->
      maps:map().
  get_times_changes(#change_req{
      fields = Fields,
      exists = Exists
  }, _, Doc = #document{value = #times{}}, State) ->
      #{<<"times">> => get_record_changes(true, Fields, Exists, Doc, State)};
  get_times_changes(#change_req{
      always = true,
      fields = Fields,
      exists = Exists
  }, FileUuid, _, State) ->
      {ok, Doc} = times:get(FileUuid),
      #{<<"times">> => get_record_changes(false, Fields, Exists, Doc, State)};
  get_times_changes(_, _, _, _) ->
      #{}.
  
  
  %% @private
  -spec get_custom_meta_changes(change_req(), file_meta:uuid(), datastore:doc(), map()) ->
      maps:map().
  get_custom_meta_changes(#change_req{
      fields = Fields,
      exists = Exists
  }, _, Doc = #document{value = #custom_metadata{}}, State) ->
      #{<<"customMetadata">> => get_record_changes(true, Fields, Exists, Doc, State)};
  get_custom_meta_changes(#change_req{
      always = true,
      fields = Fields,
      exists = Exists
  }, FileUuid, _, State) ->
      {ok, Doc} = custom_metadata:get(FileUuid),
      #{<<"customMetadata">> => get_record_changes(false, Fields, Exists, Doc, State)};
  get_custom_meta_changes(_, _, _, _) ->
      #{}.
  
  
  %% @private
  -spec get_file_meta_changes(change_req(), file_meta:uuid(), datastore:doc(), map()) ->
      maps:map().
  get_file_meta_changes(#change_req{
      fields = Fields,
      exists = Exists
  }, _, Doc = #document{value = #file_meta{}}, State) ->
      #{<<"fileMeta">> => get_record_changes(true, Fields, Exists, Doc, State)};
  get_file_meta_changes(#change_req{
      always = true,
      fields = Fields,
      exists = Exists
  }, FileUuid, _, State) ->
      {ok, Doc} = file_meta:get({uuid, FileUuid}),
      #{<<"fileMeta">> => get_record_changes(false, Fields, Exists, Doc, State)};
  get_file_meta_changes(_, _, _, _) ->
      #{}.
  
  
  %% @private
  -spec get_file_location_changes(change_req(), file_meta:uuid(), datastore:doc(), map()) ->
      maps:map().
  get_file_location_changes(#change_req{
      fields = Fields,
      exists = Exists
  }, _, Doc = #document{value = #file_location{}}, State) ->
      #{<<"fileLocation">> => get_record_changes(true, Fields, Exists, Doc, State)};
  get_file_location_changes(#change_req{
      always = true,
      fields = Fields,
      exists = Exists
  }, FileUuid, _, State) ->
      {ok, Doc} = file_location:get(FileUuid, oneprovider:get_id()),
      #{<<"fileLocation">> => get_record_changes(false, Fields, Exists, Doc, State)};
  get_file_location_changes(_, _, _, _) ->
      #{}.
  
  
  %% @private
  -spec get_record_changes(boolean(), [term()], [term()], datastore:doc(), map()) ->
      maps:map().
  get_record_changes(Changed, FieldsNames, ExistsNames, #document{
      revs = [Rev | _],
      mutators = Mutators,
      deleted = Deleted,
      value = #custom_metadata{value = Metadata}
  }, _State) ->
      Fields = lists:foldl(fun
          (<<"onedata_keyvalue">>, Acc) ->
              KeyValues = case maps:without(?ONEDATA_SPECIAL_XATTRS, Metadata) of
  