bugfix and logging improvement