logging fixes; memory leak fixes