Closes #12: improved handling of pipes and signals. Thanks to Andrew Garner for the patch and suggestions.