Optimize midentify script to not wasted time filling the cache.