Bugfixes, minor improvements and modifications