better logging, bugfixes