More fixes to the cosine caching