Bugfixes, minor improvements