don't use marsenne twister prng
some cleanup/fixes
add WRITE_PROB constant