Added memoization decorator.