Caching producing unwanted results