further caching and optimizations