Some improvements to flow, and some new functions