Backport a few clang fixes

This is a smaller subset of clang related fixes. Should merge better than the larger chunk.