Adds printing of inter-leaf distances (to compute histograms, etc.). Also some minor code cleanup.