Additional changes so that this works for both CRuby and JRuby.