anchor.diff:  
       function GetDemandsCnt(aHouse: TKMHouse; aWare: TKMWareType; aType: TKMDemandType; aImp: TKMDemandImportance): Integer;
       procedure AddDemand(aHouse: TKMHouse; aUnit: TKMUnit; aWare: TKMWareType; aCount: Integer; aType: TKMDemandType; aImp: TKMDemandImportance);
  -    function TryRemoveDemand(aHouse: TKMHouse; aWare: TKMWareType; aCount: Word; aRemoveBeingPerformed: Boolean = True): Word; overload;
  -    function TryRemoveDemand(aHouse: TKMHouse; aWare: TKMWareType; aCount: Word; out aPlannedToRemove: Word;
  -                             aRemoveBeingPerformed: Boolean = True): Word; overload;
  +    function TryRemoveDemand(aHouse: TKMHouse; aWare: TKMWareType; aCount: Integer): Word; overload;
  +    function TryRemoveDemand(aHouse: TKMHouse; aWare: TKMWareType; aCount: Integer; out aPlannedToRemove: Integer): Word; overload;
       procedure RemDemand(aHouse: TKMHouse); overload;
       procedure RemDemand(aUnit: TKMUnit); overload;
   
  
positive.code: end;
  
  
  function TKMDeliveries.TryRemoveDemand(aHouse: TKMHouse; aWare: TKMWareType; aCount: Word; aRemoveBeingPerformed: Boolean = True): Word;
  var
    plannedToRemove: Word;
  begin
    Result := TryRemoveDemand(aHouse, aWare, aCount, plannedToRemove);
  end;
  
negative.code:       else
        begin
          //Collect all performing demands first (but limit it with `NEEDED - FOUND`)
          if (planned < aCount - Result) then
          begin
            if Length(plannedIDs) = 0 then
              SetLength(plannedIDs, aCount); //Set length of plannedIDs only once
  
            plannedIDs[planned] := I;
            Inc(planned);
          end;
        end;
        if Result = aCount then
          Break; //We have removed enough demands
      end;
  
      //If we didn't find enough not performed demands, mark found performing demands as deleted to be removed soon
    for I := 0 to Min(planned, aCount - Result) - 1 do
    begin
      Inc(aPlannedToRemove);
      fDemand[aWare, plannedIDs[I]].IsDeleted := True;
      fDemand[aWare, plannedIDs[I]].DeleteState := ddtDeleting;
    end;
  end;
  
  
  