Various fixes to improve the build system.