Fixed major issue with loyalty calculation.

Loyalty was being switched whenever the number of purchases from each manufacturer was different. Both the device and host functions have been updated to fix this issue. The intended behaviour is to be loyal to the manufacturer from whom most purchases have been made on that day.