More refactoring on SegmentBySegment/main, added some comments on possible unused code