continued refactoring and jsdoc comments