Fixes #6587 and #6590

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