Clean up the code to build successfully on macOS