issue #24 code optimization for CodeGenerator and DiagnosticActivity