Fix many bugs in sampling, and add logging. Randomization seems to be
good now