First round of jQuery refactoring