Add caching of case expressions