Incorporating all feedback from Jeremy Yallop
Simplifying the body of swapf