Build system: Improvements and cleanup in build script for OSX