Fixedd up flow.h, needs to be tested