Some fixes to enable OS X support