Fix bugs in diagnostics found by Ron Savage.