various improvements to logging and error messages