made pipe lazier, and simplified implementation

This is totally untested, but I think it's right. Review by @pchlupacek