Made swap a function to prevent awful error messages from macros.