clean up some stream code