Fixes and features.

See individual commits for more details.