Problems with newer versions of JQuery

Some error handling to handle some assumptions that are no longer valid.