Bugfixes + logging