fix portability issues for use on osx