preliminary mavericks support

Merging in upstream changes ahead of an official upstream update to support OSX Mavericks.

Also fixes issue #7