Refactored transient caching and unit tests.