Fix bugs with flows