Reorganize some peg drawing code