rewrite sorting of features
cleanup
fixes