Improve logging, close #2261