bug fix: flush only dirty buffers