Several small cleanups
This branch has a miscellaneous collection of small cleanups that I found in the course of other refactorings. Indivually they are all fairly minor so I don't think they warrant a CHANGES note, but I have collected enough of them that it's time to merge before the review task gets too big.
Edited by Tony Finch