Bugfixes and corrections