Cleans up Mac js implementation.
Adds doc comments.