More compatibility tweaks. Works under 1.8.7, 1.9.3, 2.0.0, JRuby 1.7.4