Add Ruby 1.8.7 compatibility
Merge branch 'ruby_187_compat' into staging