delete some old code and add bendpoint insertion for issue #25