refactor so input and output streams can be changed
0.4.16 - be able to swap input and output streams