Cleanup cache implmentation, and add per-use configuration.