Memoization improvements.