Fixes in handling endianness of the return code