Various general improvements

See the individual commits.