Fixes to get everything building.

Applying these changes got everything building for me on OS X 10.9.4. See commits for more details.