Code cleanup (phase I)