Memoized functions optimization.