Added memoize decorator.
Incomplete attempt at PE #243.