Move stream functions to own module

Also remove doctests which for some reason don't work on travis