Added a Channel class, and abstracted out the swap function.