Patches to make it compile on Mac