Various bugfixes

Fixes #3482
Fixes #2469
Fixes #3928
Fixes #3863
Fixes #3769