Added caching using memoize module.