Improve EXTRACT_VECTOR_ELT patch based on comments from Duncan