Massive code cleanup.