Backported 3c54e70. Corrected upgrade template's handling of unenforced payments.