Adding per-case cache to optimize