Improved diag code.
better diag code.
Merge branch 'test' into dev