anchor.diff:  eval_rates(#linear_rate{from_fun = FFun, to_fun = ToFun, from = OldF, to = OldT} = RateState, Done, CurTime, Time, State) ->
       {F, State1} = FFun(State),
       {T, State2} = ToFun(State1),
  +    % If rate changes we have to change number of "done" iterations accordingly
       NewDone =
           case {F, T} of
               {OldF, OldT} -> Done;
               {_, _} when OldF == undefined -> Done;
               {_, _} ->
  -                Tm = CurTime,
  -                A = F + (T - F) * Tm / (2 * Time),
  -                B = OldF + (OldT - OldF) * Tm / (2 * Time),
  +                % Calculating areas under new and old ramp graphs (which are trapeziums)
  +                % Kinematic equations also could be used (S = v0*t + a*t^2/2)
  +                A = F + (T - F) * CurTime / (2 * Time),
  +                B = OldF + (OldT - OldF) * CurTime / (2 * Time),
                   round(Done *  A / B)
           end,
       {RateState#linear_rate{from = F, to = T}, NewDone, State2}.
  
positive.code:                 end
              end
          end,
      ArgEvaluator =
          fun (Name, Spec, Default) ->
              case lists:keyfind(Name, #operation.name, Spec) of
  
negative.code: 
  eval_rates(#const_rate{rate_fun = F, value = Prev} = RateState, Done, CurTime, _Time, State) ->
      {Rate, State1} = F(State),
      % If rate changes we have to change number of "done" iterations accordingly
      NewDone =
          case {Rate, Prev} of
              {Prev, _} -> Done;
  