Improve elastica and fix bugs