Code cleanup. Added JSDoc to functions that were lacking.