Update CiviDiscount code 

These changes are mostly already in master. Major overhaul of code for readability reasons combined with adding configurable discount options