Several fixes in case jQuery is overwritten by other libraries on the page.