t672 fix 508 issues and format code
Merge branch 't672' into resolved