Bugfixes and better logs