Misc build fixes

Small improvements to the build scripts.