add a flush interval timer and flush stuff, also move the flushing to a subprocess to not be too heavy on latency