Bugfixes and enhancements