General fixes

OS X build fixes and general fixes