Negative karma decay

I finally got around to playing with the karma decay on a copy of our data and discovered bugs related to the handling of terms that had negative values when the actions were created on upgrade.

The following code fixes the the upgrade process. It does not currently fix previously upgraded data. Do you think that is worth doing? I can create a separate upgrade process for that if necessary.

(You probably want to compare files with `?w=1`, since I changed little code in comparison to the indentation changes)