Create generic stream reader for streams

Also, put some utility code in their own files.