Added invariant checks and random seed.