fix compiling bugs on MacOSX