optimizes caching (WIP)

fixes #2267