Changed the interface to use Stream, for Issue #9. This is more memory efficient, more changes probably needed