reformat code and remove unused code