Mac fixes

Changes required to be able to compile under OSX