Unify byteswapping functions, and avoid nonportable versions.