Fix a couple bugs with types and endianness