main: algorithm to draw links fixed, draw only once

The previous, lazy way to do it was wrong. It was so simple.