Fix data type and offset bugs