Added more comments to explain the inner working of the segmentation
algorithm.