Made a start at pulling stream logic out
Mre stream refactoring
Can now pass in a stream to write the filtered output to