Added some random model checking.
resolved some small merge conflicts