More JS Refactoring