Improve error reporting and scanning