Added some guards around OS X commands