Fixed 64bit unsigned longs and sample calculation and a few other small things.