Memoize a few expensive functions