Improve SwitchIn and add statistical functions