WIP Javascript refactoring
More Javascript refactoring