Fix the build, including fixes for MacOS