Bugfixes

various bugfixes, see individual commits