Minor fixes on flushing function