LRU Caching and some code cleanup