minor diagnostic formatting improvements and refactoring