Refactor creation of stream endpoints

At the moment the code for the stream endpoints (s0,s1,s2,s3,s4) is just copy-pasted code. In addition only the endpoint s0 has environment variables mapped to its settings.