More work on distance computation.