Needs cleanup, but adds some caching to reduce api calls and improve performance