Substantial rework of error reporting, rolled to 1.6.0