Add program-wide random generator, and deep copy
Add more tests.