Applied Jamie's patched with deallocating bug