Added memoization style cache to Library.