multiple improvements to the output and regs for switch