Fixes for building on OS X

Tested and works fine on OS X 10.9.5