Fix 4 issues

This PR covers all OS X Mavericks issues that I've recently discovered in my testing on a clean Mavericks install. (And reinstall to test idempotence.)

Here's an install log for the [first install on a clean Mavericks](https://gist.github.com/gohanlon/d0e694667ad5e15cfba1) and a the [second install](https://gist.github.com/gohanlon/2cf6a178831c54e2d484) to show idempotence.
@mike-burns I think you're question about `cut` instead of `awk` was targeted at the next line, but just in case: I believe `awk` is best here because the output of `brew ls --versions` looks as follows when more than one version is installed:

    openssl 1.0.1e 1.0.1f 1.0.1g 1.0.1h

The latest version installed is the last field in the line, and I'm not aware of a clean way to get the last field using `cut`.