fixup memleak
WIP; does not build yet
wip