code re-org for diag module.