Fix memory access on 64-bit architecture

sizeof(long) == 8 on 64-bit, resulting in invalid reads.
Fix printf types