Improve JRuby compatibility