fixes for osx, needs testing on win32