improve logging and fix small bugs