Add memoization to avoid exponential parse times