Better error detection and reporting