Fix compilation on MacOSX and fix some warnings