Various bugfixes

Passes partests on 2.11 branch (but not all buglisted bugs are resolved)