fix: NPE in initializeWriter
wip: fixing memory leaks