Major bugfixes in discountcodes

Now used codes are deleted