JSDoc and a bit of refactoring
Refactoring and documentation