Fixes memory leaks in IO-streams

TODO:
- Minor leaks
- Dropped/duplicated samples
- Truncates at end (see ringbuffer -> stream adapter)

See #54