Fix jquery detection, optimise.