updated build script: added better handling for OSX
updated build script