OSX Compatibility

Some fixes to compile on OSX with clang.