Make gem work for jruby 1.8.7 and simplify design