Minor refactoring and improvements to the switch smoothing logic