Pipe Chunk Boundary Optimization

Backport from 3.5.0