fix style errors and add jsdoc comments