anchor.diff:      FirstSum = safe_sum(FirstPart),
       FirstAvg = safe_avg(FirstSum, FirstLen),
       Rest = safe_tail(Window, Values),
  -    lists:reverse(moving_average(Rest, Values, FirstSum, FirstLen, [FirstAvg])).
  +    FirstValue = get_value(safe_last(FirstPart), FirstAvg),
  +    lists:reverse(moving_average(Rest, Values, FirstSum, FirstLen, [FirstValue])).
   
   
   moving_average([], _Last, _Sum, _Len, Acc) -> Acc;
  
positive.code:                       % fetch additional past data
                        [S] = fetch_data([S0#series.target], From-(WindowPoints * Step), Until, Now),
                        Values = moving_average(S#series.values, WindowPoints),
                        WithTimestamps = with_timestamps(Values, S0#series.start, S#series.step),
                        S#series{values=WithTimestamps, start=S0#series.start, until=S0#series.until}
                end, Series);
  
  % multiplySeries
  
negative.code:     NewSum = Sum + Sum0 + Sum1,
      NewLen = Len + Len0 + Len1,
      Avg = safe_avg(NewSum, NewLen),
      moving_average(Xs, Ls, NewSum, NewLen, [get_value(X, Avg) | Acc]).
  
  
  get_value({TS, _}, Value) -> {TS, Value};
  get_value(_, Value) -> Value.
  
  
  with_last_value(null) -> {0, 0};
  