Fix jQuery timing errors