Merge "Clean up the code to build successfully on macOS" into devel/master