Performance improvements, particularly for JRuby

This patch is 1.99x faster on MRI, 1.85x faster on RBX, and 41.4x on JRuby.

This makes JRuby 2.6x faster than MRI when the JVM is warm.

Further gains could be had from switching to strings from symbols or at least reducing the number of .to_s and .to_sym calls.