Misc fixes.

See individual commit messages.