issue #8 resolved, however still leaking memory