Fix misc formatting issues
See commits for details.
This is somewhat opinionated, but cleaning up formatting makes it easier for me to read code, make changes and commit cleanly formatted code without extra whitespaces myself. I don't enjoy having to do extra work to add e.g. trailing whitespace back after my editor removed it to make new commits that don't have any unrelated changes. Also I feel that things like not having extra trailing whitespace should be pretty universally accepted best practice by now.