endianness refactoring