Payday rewrite, part 1

Step 2 of #2508. Follow-on from #2489.