Bugfix/issue 294 caching broken

Fix is improving performance but is more like a quick solution than solving the underlying complexity problem. More to come.