anchor.diff:        else
         begin
           //Collect all performing demands first (but limit it with `NEEDED - FOUND`)
  -        if aRemoveBeingPerformed and (aPlannedToRemove < aCount - Result) then
  +        if (planned < aCount - Result) then
           begin
  -          if Length(PlannedIDs) = 0 then
  -            SetLength(PlannedIDs, aCount); //Set length of PlannedIDs only once
  -
  -          PlannedIDs[aPlannedToRemove] := I;
  -          Inc(aPlannedToRemove);
  +          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 aRemoveBeingPerformed then
       //If we didn't find enough not performed demands, mark found performing demands as deleted to be removed soon
  -    for I := 0 to Min(aPlannedToRemove, aCount - Result) - 1 do
  -    begin
  -      fDemand[aWare, PlannedIDs[I]].IsDeleted := True;
  -      fDemand[aWare, PlannedIDs[I]].NotifyLocHouseOnClose := aRemoveBeingPerformed;
  -    end;
  +  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;
   
   
  
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: 
  //Attempt to remove aCount demands from this house and report the number
  //if there are some being performed, then mark them as deleted, so they will be cancelled as soon as possible
  function TKMDeliveries.TryRemoveDemand(aHouse: TKMHouse; aWare: TKMWareType; aCount: Integer; out aPlannedToRemove: Integer): Word;
  var
    I, planned: Integer;
    plannedIDs: array of Integer;
  begin
    Result := 0;
    planned := 0;
    aPlannedToRemove := 0;
  
    if gGameParams.IsMapEditor then
  