Second, if everything proceeds well, is it possible for the order to reach OrderState.Cancelled without first reaching OrderState.PendingCancel?
Third, can one expect different behaviour on live and Sim accounts? Asking this because the code below may sometimes print "Cancelling buy" dozens of times before the order gets cancelled on Sim. Haven't noticed this when trading live.
if (buyOrder != null)
{
if (buyOrder.OrderState != OrderState.PendingCancel)
{
Print("Cancelling buy");
CancelOrder(buyOrder);
}
return;
}

Comment