Replace each_with_object with reduce
Test against Ruby 1.8.7