Various fixes for OSX