Added memoization to Ginseng.