Mac OSX Fixes

This adds fixes for compiling and running on Mac OSX