refactoer internal message queue (from chanel to io.Pipe)