Simplify and optimize flat_map [#84]