Tried improving caching but think it was already optimal.