Move shunting logic out into its own class