Fixed endianness and made comply to the spec.