Fix some bugs with path handling.
Correct errors on Darwin.