Various fixes

Two fixes, see individual commit messages.