Fix vairous issues with compile for Mac (and maybe others).