Cleaned up the swap function a bit...