OS X: Library

This is first draft. It needs thorough analysis and checks to make sure it doesn't break Linux. Please comment were things are inappropriate etc k-thx-bye :)