Refactor js

@stewartmccoy please merge the refactor-js branch in to the devel branch. All issues from the refactor should be fixed now. I've done QA, but please QA on your end as well. Thanks.