Fix/writer mem leak