Added backports to workaround problems on Ruby 1.8