Added changes to fix building on OS X