more refactoring, make pipe more like node's
simplify file API to simple read/write