szbwriter - fixed memory management issues

* Previos change introduced some memory leaks
which had to be fixed.