Move StreamFactory to outer util package.