Some speedups and distance computation