improved error reporting and handling