Fix a few issues.

Fixes #5011 and #5002 .
I can do that.