fixed some things to make it work on macosx