Fix jQuery vs DOM errors