Introduce sparse flows and masks, to reduce memory usage and improve speed.