Refactoring/cleaning up web JS