Tiny code cleanup

Here are a few miscellaneous fixes/cleanup patches I came across while fixing other issues.

(Whoops — I based this branch off my other branch also that also has PR now.  The duplicate shared commit will vanish when either of the PRs get applied.)