While working on a followup, I noticed that this patch runs temporary cleanups in the wrong order. Fixed (and tested) thus. Tested x86_64-pc-linux-gnu, applying to trunk.