Fix concurrency related bug in pipes