refactor streams, finish tests and docs