Cache stats and optimization

Time stats with exporting to json added.
Running time optimizations.
New erase strategy in cache.