bugfix and logging