improved OS detection and mac OSX support