Improve documentation, add JSDoc function annotations