Fixed some build errors on mac osx
Fixes crashing bugs