Various Mac OS fixes
Conditionalize Mac-specific stuff and put it in its own file.