More code-janitor work

General cleanup, untested like my last pull request, which may be more of a problem since there are somewhat bigger changes.

For the Least Authority audit I got familiar with this code, and noticed places where it looks like the code could be simpler or less fragile. It's easiest to share these observations in the form of a patchset, but that's all they are, suggestions like "couldn't you write this this way?" If the reason for any is unclear, please ask.