Minor tweak, free memory, init rand.