Fixes for building on OS X

Tested and works fine on OS X 10.9.5 (build with `make osx` for proper linking)