Various fixes, mostly style.

This is the same as the other pull request with all commits in one.