flow.py: code cleanup