Updated flush mechanism

New signature has to be created after every flush call as the output buffer will likely be cleared by the calling application