fix some bugs to do with jQuery upgrade