MODE-2040 Updated code to better support OSX.