Organizing and refactoring the Javascript SDK