Improve logging and code style.