Fix id type and tweak stats indexing