Fixed pre-mature memory deallocation.