The broken line code now works, needs major cleanup