Memory allocation optimization
Add memory deallocation