Local optimization and sorting... (: