Misc fixes.

See individual commits.