improve contour keynodes sorting; fix some bugs with contour tree output