OS X fixes from Robert Walsh