Added distance counting.