Memory leak fix WIP