Compatibility for Ruby 1.8.7

Fixes #1100.