Reworte controls, restructured code, changed toggle to latch