A bunch of code cleanup.