Bugfixes

Specific bugs listed in commits.