Various fixes for OS X