Bring in build changes for Mac, along with recent Mark changes.

The comparison is a bit conflated as I merged in Mark's recent master-branch changes as well.