Fix some endianness bugs