Small JS refactoring.
Merge pull request #49 from dayflower/small-js-refactor

Small JS refactoring.