various bugfixes and related stuff