Reduce Stream class complexity and fix some phpdoc comments