clean up code and fix bugs for curves and elbows