Fix some bugs in Flow, add Flow.keys()