Fixed more 64-bit bugs (now passes all relevant tests)