improved handling of endian