Applied changes to make it compile on darwin