Starting to refactor segment drawing code into segment.py