Added needTaskIds flag and made writing buffered.