TODO: CUSTOM_index_exn provide dense packed integers starting from 0, suitable for indexing into an array.