Fixing some 64 bit bugs