Mac OSX Fixes

This adds fixes for compiling and running on Mac OSX
Can you change this please to the main repository url?