Some general cleanups

See the commit messages for details.