High Cardinality Inverted Index Fix and cleaning up code