Portability fixes for Mac OS X.