Generate switches more efficiently.