Better error checking and reporting.