Serious code cleanup.