Major code cleanup.