Various ugly hacks to get this to work on OSX