Add docstrings, implement stream inversion.