Added caching to lookups to improve speed.