Rewrote most of io-streams section