Fixing recalculateDistances

RecalculateDistances() is now O(n) instead of roughly cubic-time. This
could be optimized further with most block additions only requiring 6
neighboring-TE checks, but it's good enough for now.