Improve swap code to include more platforms.