Changes to try to fix crashing on OSX systems