More experimenting with task history cache. Cleaned up the usages of the cache.