Cleaning legacy code