Corrected memory management issue