fix some 64-bit bugs