General refactoring: now using templates instead of generator-hack and jQuery instead of hand-woven JS