Fixed some caching and some references.