Modified to enable OS X compilation