improved error reporting and logging