Fixes incorrect memory deallocation in effect