Stop caching distances, this saves a lot lot of memory.
Should see how to cache efficiently, and then start caching.