fix issues revealed on OSX