improved OS X env handling