use istreams for input, rather than raw fds; the original reason that was needed has gone, and istreams give fewer context switches
cosmetic tidy-ups to standarise template typename naming and format a bit