BUG: Bug in internal caching, related to (GH5727)

related #5727