Error reporting fixes

Subj, see individual commit descriptions for details.