Refactor
Fix endianness for length