Starting refactoring of JavaScript