Mode code cleanup