A lot of code cleanup.