Refactor little-endian writing.