Correct many mistakes

Now, the cython version assumes a table size of 10^8. Ideally, this
should be flexible. It might be advantageous to use a better random
number generator