Refactored MainSwitch into a singleton.