Changed all unsigned long ints to uint64_t for to force compatibility on 32bit platforms