legacy code cleaning