Add support for Mac OS X

This creates a factory for different APIs based on the OS.