some improvements & clarifications to distance transform code