Merge changes to support Mac OS X 10.7 Lion into master

Although this is not tested against Mac OS X 10.6 Snow Leopard, it should also work on that version of OS X.