refactoring code to separate train_tracker into stop_detector, shape_detector and trip_matcher