Code refine, formatting fixes