Fix turn-around issues and make algorithms more able to cope with zero-distance calculations