replaced dup with dup2 for stderr
various patches to improve language, and C-code style by Daniel Kahn Gillmor