Slightly slower, much safer way to memoize the keys lookup for document loading.