Part 2 of code cleanup
Part 3 of code cleanup (final)