Cleanups and build improvements

Some cleanups and build improvements.

Not yet ready for review, here to start CI builds.