Use flat_map over collect + flatten for speed/readability.

Enumerable#flat_map is in 1.9.3+
http://ruby-doc.org/core-1.9.3/Enumerable.html#method-i-flat_map

https://github.com/JuanitoFatas/fast-ruby
http://work.stevegrossi.com/2014/10/25/writing-fast-and-idiomatic-ruby/

cc @Fryguy