Bugfixes

Specific bugs listed in commits.

Resolves #4221
Resolves #4268