changed OS detection routine to use sys library, and added support for OS X platform.