Simplify osx code
Add documentation