some changes
fixed SIGPIPE errors