fix jquery clobbering, add better error handling