code restructuring, clean up