Optimizing switches