More cleanup, improve logging