Fix mac builds Patch by Wolftrac.
Merge branch 'bugfixes' into 3.1