merge and fixed build for MacOS