Partially fixed build process on Mac OS X. Need more tests.