a bunch of byteorder fixes