some endianess bugs fixed