some refactor and reformat

no function change
more refactors and formating
continued work on refactoring