Fix some bugs with the handling of indices in insertvalue/extractvalue.