repairing some errors with the secondary index and some errors with counts