Eliminate redundant swap functions