Improvements to the build system.

More consistent now across all platforms.