Backport more RVM compatibility fixes from the 4.0 branch.