factor Stream out of the main server