Fix bad index lookups in remove and update