model rewrite: flowgraph and legacy stuff