small fixes to lj, improve rng