fix indexes when changing type of an instance