anchor.diff:  
   procedure TKMHouseMarket.ResAddToIn(aResource: TKMWareType; aCount: Integer = 1; aFromScript: Boolean = False);
   var
  -  ResRequired, OrdersToDo: Integer;
  +  resRequired, ordersToDo: Integer;
   begin
     //If user cancelled the exchange (or began new one with different resources already)
     //then incoming resourced should be added to Offer list immediately
     //We don't want Marketplace to act like a Store
     if not aFromScript then
       Dec(fMarketDeliveryCount[aResource], aCount); //We must keep track of the number ordered, which is less now because this has arrived
  +
     if (aResource = fResFrom) and TradeInProgress then
     begin
       SetResInCnt(aResource, fMarketResIn[aResource] + aCount); //Place the new resource in the IN list
       //As we only order 10 resources at one time, we might need to order another now to fill the gap made by the one delivered
       resRequired := GetResRequired;
  -    if ResRequired > 0 then
  +    if resRequired > 0 then
       begin
  -      OrdersToDo := Min(aCount, ResRequired);
  -      Inc(fMarketDeliveryCount[aResource], OrdersToDo);
  -      gHands[fOwner].Deliveries.Queue.AddDemand(Self, nil, fResFrom, OrdersToDo, dtOnce, diNorm);
  +      ordersToDo := Min(aCount, resRequired);
  +      Inc(fMarketDeliveryCount[aResource], ordersToDo);
  +      gHands[fOwner].Deliveries.Queue.AddDemand(Self, nil, fResFrom, ordersToDo, dtOnce, diNorm);
       end;
       AttemptExchange;
     end
  
positive.code:   //it looks bad that serfs remove the stone then take it back. To be converted to todo item.
  
    //How much do we need to ask to add to delivery system = Needed - (Ordered + Arrived)
    ResRequired := GetResRequired;
  
    if fTradeAmount <> 0 then
    begin
      movedOut2In := MoveResOut2In(fResFrom, ResRequired);
      if movedOut2In > 0 then
      begin
        //Remove demands, we took some of the wares from OUT queue
        OrdersRemoved := gHands[fOwner].Deliveries.Queue.TryRemoveDemand(Self, fResFrom, movedOut2In);
        Dec(fMarketDeliveryCount[fResFrom], OrdersRemoved);
      end;
    end;
  
    OrdersAllowed := MAX_RES_ORDERED - fMarketDeliveryCount[fResFrom];
  
    Assert(OrdersAllowed >= 0); //We must never have ordered more than we are allowed
  
    //Order as many as we can within our limit
    if (ResRequired > 0) and (OrdersAllowed > 0) then
    begin
      OrderToDo := Min(ResRequired, OrdersAllowed);
      Inc(fMarketDeliveryCount[fResFrom], OrderToDo);
      gHands[fOwner].Deliveries.Queue.AddDemand(Self, nil, fResFrom, OrderToDo, dtOnce, diNorm)
    end
    else
      //There are too many resources ordered, so remove as many as we can from the delivery list (some will be being performed)
      if (ResRequired < 0) then
      begin
        OrdersRemoved := gHands[fOwner].Deliveries.Queue.TryRemoveDemand(Self, fResFrom, -ResRequired);
        Dec(fMarketDeliveryCount[fResFrom], OrdersRemoved);
      end;
  end;
  
  
negative.code: 
  procedure TKMHouseMarket.AttemptExchange;
  var
    tradeCount: Integer;
  begin
    Assert((fResFrom <> wtNone) and (fResTo <> wtNone) and (fResFrom <> fResTo));
  
  