Fix flush logic.
Merge pull request #23 from dnephin/revert_select_on_all_pipes

Fix flush logic - take 2