Code cleanup phase 3