First round of code cleanup