Added the option to flush immediately