Add caching for smoother rendering.