Implemented random generators. Fixed some minor bugs.