Fixes and improvments for OS X