Added memoized computation and timing functions