Refactor of indexes and more test coverage