Reverted the memory leak fix. Will have to investigate further.