Made swap a function to prevent awful error messages resuting from the preprocessor macro.