cleaned up byteswap code