Various error reporting and logging improvements