Reducing code in stream.py

Some more code reduction and organization. Minor stuff really.