Some timing modifications; distance computation is slowest part by far