unify tee functions, clean things up

Prepare for multi-tee (writing to multiple files at the same time.
allow output to multiple files