Fixed various bugs in buy and generate goods

buy! had an endless loop caused by cheapest producer returning producers without any supply