Restore 475e77be0e3a28e7aeb1cee199620be88712edad to fix issue with discounts on referral calculations. #441