Try this fix.

The code now matches the badgercoin source. I migrated a check for negative values from badgercoin but left it commented out for now.