fix for piped input stream checking writer thread id without waiting for
the writer thread to start, also some other ordering tweaks