Merged Ken's trackSegment class with mine.