flow: better memory management