Get rid of timer and use a write timeout for flushing periodically.