Code refactoring. Add missed code comments and jsdocs