Fix some issues when running on OSX