javascript refactoring, file reorganization