Fixed #3: Added mean distance calculation.