various improvements and bugfixes