Moved (from pop distort) some stream helper functions