Tighten up logging and error reporting