logs and sorting improvements