code cleanup and reformat.