Fix index values encoding

This refs affinitic #5883