fixed some bugs with handling pipes