Fixed more 64-bit bugs. Now passes most tests