Replace flat_map with map .. flatten to restore 1.8.7 compatibility

Sorry about this. Please merge and release a new version ASAP to fix 1.8.7 compatibility