Bug fix for Average Distance that rarely caused a crash