Added caching functionality.