Updated to use pickle caching for speed and modularity