ok, somewhat fixed the memleak