Move processing segment['mode'] to segment.py