Miscellaneous improvements.

Feel free to cherry-pick if you don’t want some of them.