Decouple optimization code from drawing code
The existing code tightly couples the optimization functions to the drawing backend. The optimization aprt should output a list of stages with the corresponding operations (torsion, crossing). The outputting part would then use this as input and transfotm it into a graphical representation (svg) or any other suitable output format (JSON for example).