Fix calculation of distance
Fix weighing