Added more error checking and allowed forward compatablilty for Mac OS