Replace global with memoized method

For @rodjek.