WIP: refactor into stream interface