Improved portability to OSX