Fixes #6587, #6590, #6597, #6591

As in title.

Fixes #6587.
Fixes #6590.
Fixes #6597.
Fixes #6591.