There are two attributes set earlier in this function, "type" and "index", that I think are unused and we may want to take this opportunity to get rid of them.