Refactoring js for new usage.