Refactoring JS to use jQuery more completely.