Added OS X support and cleaned up lib.