fix get_block_stats to only look at blocks in the time window, and adds caching back