Merge changes in common; move dir into common
Merge common changes

* Move directory functions into common
* Move OS X specific changes into non-GNU