Fix threading issue which was causing a memory leak. Basically the writes were getting added to the in flight map after they were enqueued to get written and in that time span they could be been processed and the remove() would occur before the add witch caused the leak.