Fix endian porting issues