bugfixes and logging