Adding more bug fixes and the random rhs (commented out).