Fix keyval iteration