changed discount handling
Merge origin/master