Bugfixes for running on OS X