MPICH-related fixes

This is a combination of #1101 by @geimer and #1072 + #1073 by @ocaisa, and is mainly created for convenience of testing/reviewing and making minor stylistic changes.

The changes in #1101, #1072 and #1073 are all somewhat related, so it's important to tackle all of them together in one go.

@geimer, @ocaisa: if you happen to make any further changes to your open PRs referenced here, please let me know. As far as I know, they should be ready now, so I don't expect anything to be still missing here.