OSX compatibility

Now with just the compatibility changes, no Mac target.