fixed some byte-order issues