Some reformat and refactor