Fix mac builds Patch by Wolftrac.
Merge branch 'bugfixes' into releaseBranch/3.1.2