cleanup, refactoring and added linting for js