Fix build error and some warnings in Mac