Refactor main class
Add config option for switch timeout