=rem #3960 Optimize EndpointWriter

* Replace stash with internal buffer
* Replace FSM with become