Fix CMake build
Fix the build on Mac OS
Fix some compiler warnings from clang