Cache run_stats values and invalidate caches automatically.

Fixes #26