Correcting various endianess issues