Add some documentation to js functions and some housekeeping.