Rewrite to support swapping exchange operands
Code organization