fix encoding problem, improve logging