Fixes to allow compiling on OS X