Downgraded the use of flat_map to map.flatten instead so that this works on 1.8.7
Merge pull request #1 from robkinyon/fixes_for_187

Downgrade the use of flat_map to map.flatten instead